Support » Fixing WordPress » Display content only if page is part of specific menu?

  • If have some PHP code that I need to display only on pages (not posts) that are part of a specific menu. So for example, within my Primary Menu, I have a menu item of ‘Products’ and then under ‘Products’ I have a few sub menu items.

    What I want is for this code to only show on the pages under the menu item of ‘Products’ – is that possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • did you find a solution? i also have this issue which i cant find how to solve it…

    oh i found it… its that easy but to find the api ( get_post_type( $post->ID ) ) it wasnt xD.
    as an example:

    <?php if( get_post_type( $post->ID ) != 'event' ) : ?>
                <div class="news-comment"><a href="#respond-wrap" class="btn"><i class="icon-comment"></i><?php echo __( 'Kommentieren' ) ?></a></div>
                <div class="clear_float"></div>
                <?php endif; ?>

    I’m having a similar problem. I have a specific nav menu called ‘wiki menu’ which is floated left. On the right I have the sidebar content area which is floated right so when you click a link on the left, the content for that would show on the right.

    This is what I have so far:

    I want to be able to show all the content from the pages which are in my specif ‘wiki menu’. I don’t want content from my main navigation to display.

    ‘<?php $postid = get_the_ID(); ?>

    <?php $the_query = new WP_Query( ‘page_id=38’ ); ?>

    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    <?php the_excerpt(); ?>

    <?php endwhile;?> ‘

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display content only if page is part of specific menu?’ is closed to new replies.