Support » How-To and Troubleshooting » Category Specific Menu

Category Specific Menu

  • Ok,

    What i would like to do is create a menu on my category pages are regular category pages, that figures out what the current category is and display the posts under that category.

    ex// If i have 10 caetgories and the user clicks on the design category, when they are on the design category page I would like to display a menu that shows the other posts that are under the design category.

    I’ve searched and search on this and I just can’t seem to figure out of if this is possible, I know if the design category was a specific page there would be lots of ways to do this because I could set a template tag or a plugin to display a specific category id, but since it is dynamic is there a way to store the category id in a variable and then drop that variable into.. something like this:

    $posts = get_posts(‘numberposts=10&order=ASC&orderby=date&category=”%categoryidvariable%”‘);
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_title(); ?>
    <?php endforeach; ?>

    I think this would make it dynamice depending on the page.. I’m not a php expert and I’m not sure how to store the category id in a variable… or if this is even possible.. any thoughts??

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am now thinking I need to somehow drop…

    $posts = get_posts(‘numberposts=5&category=”<?php echo $catID ?>”‘);
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_title(); ?>
    <?php endforeach; ?>

    because the catID shoudl automatically be set to the current category.. when inside that category..?

    I guess nobody really cares about a solution because if you are NOT a beginner blogger then you might have 277 posts in that category… and displaying all of them in the sidebar is a nonsense.
    Just my $0.02

    This is the proper way to do this MADDDDD propts to alphaoide.

    $cat = get_the_category();
    $cat = $cat[0];
    $posts = get_posts(“category=” . $cat->cat_ID . “&numberposts=5”);
    if( $posts ) :
    <div class=”recent-posts”>
    <h2>More on this category</h2>

    <?php endif; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category Specific Menu’ is closed to new replies.
Skip to toolbar