<?php
if ( ( $locations = get_nav_menu_locations() ) && $locations[ 'primary' ] ) {
    $menu = wp_get_nav_menu_object( $locations[ 'primary' ] );
    $menu_items = wp_get_nav_menu_items( $menu->term_id );
    $pageID = array();
    foreach ( $menu_items as $item ) {
        if ( $item->object == 'page' )
            $pageID[] = $item->object_id;
    }
    query_posts( array(
        'post_type' => 'page',
        'post__in' => $pageID,
        'posts_per_page' => count( $pageID ),
        'orderby' => 'post__in'
    ) );
}
?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>

I’m using the above codes to pull all my pages based on my navigation menu within WP admin, but I would like to have an option to do specific requests based on certain pages like:

  <?php if ( is_page($slug_name) ) { do this or add this ...//where $slug_name is a page name

placed within the loop function

I tried:

  <?php if ( $post->post_name == '$slug_page') { . //where $slug_name is page name or nav item.

No success.

Can anyone hand me a hand?
I would appreciate it.
Thanks.

Read more here: how to query select page data from OnePageSite query


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: