Title: Code check: List current category post titles dynamically
Last modified: August 19, 2016

---

# Code check: List current category post titles dynamically

 *  Anonymous User
 * (@anonymized-473288)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/code-check-list-current-category-posts-dynamically/)
 * 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

Viewing 1 replies (of 1 total)

 *  Thread Starter Anonymous User
 * (@anonymized-473288)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/code-check-list-current-category-posts-dynamically/#post-747962)
 * 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](http://wordpress.org/support/topic/168512?replies=4)

Viewing 1 replies (of 1 total)

The topic ‘Code check: List current category post titles dynamically’ is closed 
to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: Anonymous User
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/code-check-list-current-category-posts-dynamically/#post-747962)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
