• Is it possible to automatically add every single post to a dropdown menu? For example, I want all posts in a category (which is the top level menu item) to be added as dropdown items to that menu.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Not unless you want to build your own dropdown using a custom query.

    Thread Starter Austin

    (@amsgwp)

    Do any plugins exist that support custom querying for dropdowns? Trying to find the quickest and easiest way to do this.

    Thread Starter Austin

    (@amsgwp)

    Here is what I ended up doing. This works with the Roots WordPress theme.

    echo '<ul id="menu-primary-navigation" class="nav"><li class="active dropdown menu-home"><a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/">';
      foreach($cats as $cat) :
        $cat_name=$cat->slug;
        echo $cat->name;
        $cat_posts = get_posts('numberposts=-1&category_name='.$cat_name);
          foreach($cat_posts as $post) :
            setup_postdata($post);
            echo '<ul class="dropdown-menu"><li class="menu-sample-page"><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
          endforeach;
        echo '</ul></li></ul>';
      endforeach;
    echo '</ul>';
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automatically Populate Menu with Post Title’ is closed to new replies.