What I'm trying to do:

On the category page for each category, instead of having each post appear separately from the other posts (i.e. in a separate container), I want to have a single list of all the posts in that category.

Each item on the list should consist of the title of the post, which also serves as a link to that post. The order should be reverse chronological (meaning that the latest post is displayed first, which is the default order). The list should preferably be in bullet-points, but this isn't crucial.

I need to do this by inserting code using an external plugin, and not by editing the original file.

What I tried that didn't work:

Originally I tried using a plugin (https://wordpress.org/plugins/list-category-posts/) which outputs the desired list using a shortcode, which I then placed in the category description. The main issue is that enabling shortcode in the description causes a bug in my theme, where the output of the shortcode is duplicated above the site's header. (In addition, I would need to ensure that the category pages don't display any posts and only display a description, which I'm not sure how to do).

Where I am now:

I've managed to get the category page to display only the titles. However, each title appears in a separate container. Not sure if I need to add to this method, or try something else entirely.

# Increase the number of posts per category page, so they all appear on one page:
function number_of_posts_on_category($query){
    if ($query->is_category) {
            $query->set('posts_per_page', 150);
    return $query;
add_filter('pre_get_posts', 'number_of_posts_on_category');

# Only display titles for posts on category pages:
function category_post_titles($content = false) {
if(is_category()) :
    global $post;
    $content = $post->the_title;
    if($content) :
        $content = apply_filters('the_title', $content);
return $content;
add_filter('the_content', 'category_post_titles');

1 Answer 1


One option would be to just replace category template with another file from the plugin using category_template filter:

function change_category_template( $template ) {
    $category_template = plugin_dir_path( __FILE__ ) . 'new-category.php';
    return $category_template;
add_filter( 'category_template', 'change_category_template', 999 );

So, in the new file you could have the structure you want.

The main problem is that you are replacing the entire template file and if you want something that would work with any theme it's more difficult to achieve that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.