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);
endif;
endif;
return $content;
}
add_filter('the_content', 'category_post_titles');