Support » Fixing WordPress » Hide "li" of menu if it doesn´t have any custom post

  • I have a menu in wordpress made this way:

    <li id="prensa_nav"><a href="?page_id=9">NEWS</a></li>
    <li id="contacto_nav"><a href="?page_id=17">CONTACT</a></li>
    <li id="curriculum_nav"><a href="?page_id=20">CURRICULUM</a></li>

    Each li opens a wordpress page that has some custom posts. The problem is that I want the Curriculum li to display only if the page_id=20 has a custom post, otherwise it should be set to display:none or something.

    Does anybody knows how to do this with a function? I´m just starting and I searched but couldn´t find something like this.

    This is the markup of the page_id=20 that get’s the custom post: **curriculum_post**:

    <?php $query = new WP_Query(
        'post_type=curriculum_post&posts_per_page=-1&order=DESC' ); ?>
        <?php while ( $query->have_posts() ) : $query->the_post(); ?>
        <div class="curriculum">
             <p><?php the_field('curriculum_dinfo'); ?></p>
        <?php endwhile; // end of the loop. ?>
  • The topic ‘Hide "li" of menu if it doesn´t have any custom post’ is closed to new replies.