• 0
Sign in to follow this  
Followers 0

Adding custom posts to categories archives

Question

Posted · Report post

Does this code look like it will properly add custom posts to my categories archives? Currently I can assign default categories to custom posts, but only "Post" post types appear in the archives.

// Define what post types to to include in archives function ecpt_add_post_type_to_archives( $query ) { if ( $query->is_archive ) { $query->set( 'post_type', array( 'post', 'custom_post_type2', 'custom_post_type3', 'custom_post_type4' )); } return $query; } add_filter( 'getarchives_where', 'ecpt_add_post_type_to_archives' );
Thanks

Share this post


Link to post
Share on other sites

13 answers to this question

  • 0

Posted · Report post

I've used this plugin with great success. http://wordpress.org/extend/plugins/map-categories-to-pages/

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Shmokes, I'm not sure why you rejected my suggestion, so please explain what's going on, and what we can do to assist you further.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I just don't see how that plugin will solve the problem I described. Perhaps I didn't describe it well. When I view my list of categories in the dashboard it says that the Books And Story Apps category contains a bunch of posts. [IMG]http://i55.photobucket.com/albums/g134/shmokes/Categories.png[/IMG] But when I go to that category's archive page, it shows zero posts. [IMG]http://i55.photobucket.com/albums/g134/shmokes/EmptyArchive.png[/IMG] It does this because all of my posts that have the Books and Story Apps category attached to them are custom post types. WordPress supports custom post types, so the category sees that all these custom post types exist. But for some reason Archive pages, by default, only show posts of the "Post" post type (i.e., not custom post type). This behavior is entirely nonsensical, of course. I can't imagine that anybody would ever [i]want[/i] their blog to behave this way. But that's the current state of things. The plugin you linked to, as near as I can tell, would allow me to make a page and attach categories to it. But that's just not what I'm trying to accomplish. For what its worth, the main page had a similar issue. Only posts of the default "Post" post type were showing up on my main page. I had to add a function to my functions.php to add my custom post types to my front page loop. I assume that similar code could be added somewhere to accomplish the same thing with my archives, but I don't know PHP so I don't really know where to begin. For now, I have come up with a workaround. Custom taxonomy archives contain posts [i]of all types[/i] that are attached to them. So I made new taxonomies to replace my categories. It's an annoying solution, and I'd still like to have my category archives working the way they should. But it's at least serving my purposes for now. Please let me know if I misunderstood your original suggestion. But as near as I can tell, it would neither fix my original problem, nor provide a workaround. In any case, I appreciate your trying to help.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Apologies, I may have misunderstood your need. As a workaround, I used Custom Press to create taxonomies and Multi-Column Taxonomy List to create a list of the taxonomies I've created. Oddly, that combination made it possible to see a category page with all the posts listed in every custom taxonomy AND every regular category. See it in action at http://www.epicurus.com/beverages

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Rengelone, I am trying to accomplish something different but since you just helped me with my other problem and I noticed you are suggesting the 'Map Categories to Pages' plugin, let me seek your advice. I want to post the most recent news post on my static homepage below the introductory paragraph. I installed this plugin thinking it would help me accomplish this goal, but I'm not quite sure how to make it happen. Tips? www.dalestrong.com Thanks! Ashley

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Ashley, You could try this plugin, http://wordpress.org/extend/plugins/show-posts-shortcode/ I haven't tried it personally but I did a search through our forums and a few members seem to have no problems with it. If this doesn't help, let us know so we can assist you further.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Unfortunatelly i have exactly the same problem as shmokes. As i see some people on this forum have serious dificulties with understanding the users questions. However this bug is not related with pagelines pro, as with default them it acts the same way. is it matter of registering thos custom type post somewhere?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

@anlinares - Try the TPG Get Posts plugin which has some easy customization options and lets you place recent posts to a page. It doesn't deal with thumbnails to my knowledge, but some editing might make that work. Another one is Mini Loops. @jankowalski - This "bug" as you call it, is actually a Wordpress, not a theme function. While it's very easy to get confused between the two, anything to do with the category creation and whether posts show up is not theme based. Likely, there is a plugin setting that created the custom post types is what's causing the problem.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Yes i wrote exactly this in my post - that it is not related with pagelines pro (read: theme function). Please re-read my post so you ll get it. I thought you might know the way how to fix it, but i think I ll try to fin solution on wordpress.org forum in this topic.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

@jankowalski The way to find a solution is to deactivate your plugins - one by one - and between each, do a hard refresh so that you may see whether the problem is resolved. Custom post types are usually created using tools, such as Custom Press or, they're created by 3rd party plugins which add them to the database when either creating tables or adding the structure to existing tables. Since I have no idea which plugins you have, there's little chance I'll know the solution. Ultimately, if you're having a problem with a plugin and Wordpress and PlatformPro is known not to be the problem, then you must address the issue directly with the plugin author for the best solution. We will, of course, try to assist as best we can, to implement anything that is theme related.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

to 2@shmokes and all facing this problem, the solution can be found here: http://wordpress.org/support/topic/custom-post-type-tagscategories-archive-page/page/2 i m not sure whether is related with wordpress or plugin.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I'm accepting Ranelone answer until @shmokes replies to this question.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Danym i have tried your solution, but this plugin doesn t work with wordpress 3.0. I don t see any category box on my new page form. have you use it recently?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0