Dropdown menu - Autoinclude posts (3 posts)

  1. sebastianoseno@gmail.com
    Posted 2 years ago #

    Hi folks, i'm having a trouble trying to build a menu for my blog. I want to create a dropdown menu with categories and my posts inside of them. I know that i can manually insert articles in a menu, but is there a way to simply put the category in the menu and have the articles belonging to that category added automatically? It would be very tedious to me to add every single article to the menu by hand picking it...

  2. shadez
    Posted 2 years ago #

    you can use this code to list posts from category:

    $args = array( 'numberposts' => 10, 'category' => 1 );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endforeach; ?>

    duplicate and use for categories...

  3. sebastianoseno@gmail.com
    Posted 2 years ago #

    and where shall i put it? how can i use code in the menu section? sorry, quite a newbie :D

Topic Closed

This topic has been closed to new replies.

About this Topic