I have been attempting to get a solution to work that was previously posted for this question 1
I created the template as posted:
<?php
/* Template Name: Multiple Categories */
get_header();
$args = array(
'cat' => '1, 5, 9',
'posts_per_page' => -1,
);
$my_posts = new WP_Query( $args );
if( $my_posts->have_posts() ){
while( $my_posts->have_posts() ){
$my_posts->the_post();
//Echo the post
}
}
wp_reset_postdata();
get_footer();
When I select this template for a page, 'view page' displays only the theme header and footer with nothing in between.
I suspect the template code is incomplete... or do I need to do something in the page itself? Or maybe the theme I'm using is keeping this from working? Suggestions?
BTW, I want these displayed just as the theme displays individual category pages - trying to use plugins like wp_list_category_posts will not do this.
the_title();
after that//Echo the post
line?new WP_Query
call), so what theme are you using? Does it have any of the category templates?<your site URL>?cat=1,5,9
, e.g.https://example.com?cat=1,5,9
.. which also means you could create a rewrite rule which redirects internally to that page. I.e. Without a URL change and without having to creating a Page or custom page template.