I'm making a category archive template that works for all my categories. I need to dynamically set the 'category'
parameter of WP_Query
inside of this template to make it work.
How do I dynamically get a string of the current category page name to feed into the WP_Query? All the methods I've seen presupposed that I know my ID
or slug
. As this is an archive page, most WP functions will not return the archive page title but rather a post title.
The best option I've see is:
$current_category = single_cat_title("", false);
But it still displays the title on my category.php
page - maybe I'm doing something wrong with this?
pre_get_posts
to alter the main query? – Milo Jan 15 '16 at 22:10