In wordpress my archive.php page is displaying my two test posts as:
Post Name 1, and
This entry was posted in 'MyCategory1' on March 02, 2013
the second one as:
Post Name 2; and
This entry was posted in 'MyCategory2' on March 02, 2013
Both posts have been added under a custom post type called projects
.
Both MyCategory1
and MyCategory2
shown above are links with a destination of:
Mysite/category/MyCategory1
or MyCategory2
for the second link.
Following the MyCategory1
link displays the post correctly, it displays like on the archive page as title and the reference to it’s category and only shows the post that’s under MyCategory1, MyCategory2 no longer appears, this is correct.
But following the second link MyCategory2 displays a message:
Nothing Found
Apologies, but no results were found. Perhaps searching will help find a related post.
Any ideas why this might be happening and not showing the post that’s under this category? The category link is created dynamically and so I cannot see why its not finding the 2nd post on the category page but is providing the link to it’s category page?
Please note I have added the following code into category.php loop to query the posts to display from custom post types as well as just the ordinary standard WP post type:
// Modify the default loop, include custom post types
global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => 'any' ) );
query_posts( $args );
while ( have_posts() ) : the_post();
Any help and suggestions appreciated. I visited the permalinks page to try and refresh this in case there was an issue there but still no result. ? I’m a bit baffled.
I’ve just added a third category as well and tried this. It also does not display and returns ‘Nothing Found’. So the only post category that’s displaying correctly at
Sitename/category/MyCategoryName
is the first one.
My Category Base and Tag Base settings under permalinks are currently blank and therefore using the WP defaults.
Thanks
I have made some progress. If I use ?post_type=projects
at the end of the url then the category displays the project’s posts for that category correctly. So I think the problem lies in that the default wp categories are not pulling in the custom post type ‘Projects’ posts successfully within the loop.
So this link works:
http://localhost/Sitename/category/CategoryB?post_type=projects
But how can I make the below link display the same as the link above?
http://localhost/Sitename/category/CategoryA
I think I need to query the posts some how so that it shows posts from the custom projects post type without the need to use ?post_type=projects.
?? Any ideas?