WordPress.org

Ready to get started?Download WordPress

Forums

Display content only if page is part of specific menu? (3 posts)

  1. Palemo
    Member
    Posted 2 months ago #

    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?

  2. webfacer
    Member
    Posted 1 month ago #

    did you find a solution? i also have this issue which i cant find how to solve it...

  3. webfacer
    Member
    Posted 1 month ago #

    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; ?>

Reply

You must log in to post.

About this Topic