WordPress.org

Ready to get started?Download WordPress

Forums

Code check: List current category post titles dynamically (2 posts)

  1. design_dolphin
    Member
    Posted 6 years ago #

    When finished this should be able to run in the sidebar/ as widget.

    The following code should work. What am I overlooking?

    <h2><?php single_cat_title() ?></h2>
    
    <?php
    $categoryvariable=$cat; // assign the variable as current category
     $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query
     query_posts($query); // run the query
    if ($myposts):
    foreach ($myposts as $post):
    setup_postdata($post);
    the_title();
    endforeach;
    else :
    // Nothing Found
    endif;
    ?>

    Thank you

  2. design_dolphin
    Member
    Posted 6 years ago #

    Solution:

    This works to show the post titles of the current category on a category page (in 2.5)

    http://wordpress.org/support/topic/168512?replies=4

Topic Closed

This topic has been closed to new replies.

About this Topic