Jump to content


Photo

Adding custom posts to categories archives


  • Please log in to reply
13 replies to this topic

#1 shmokes

shmokes

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 04 September 2011 - 11:06 PM

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

#2 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 05 September 2011 - 12:06 PM

I've used this plugin with great success. http://wordpress.org...ories-to-pages/

#3 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 16 September 2011 - 05:45 PM

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.

#4 shmokes

shmokes

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 21 September 2011 - 04:24 PM

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.

Posted Image

But when I go to that category's archive page, it shows zero posts.

Posted Image

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 want 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 of all types 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.

#5 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 21 September 2011 - 05:59 PM

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

#6 anlinares

anlinares

    Super Member

  • Members
  • 228 posts
  • Country: Country Flag

Posted 10 October 2011 - 02:10 AM

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

#7 Danny

Danny

    Is Awesome!

  • Moderators
  • 13021 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 10 October 2011 - 07:04 AM

Hi Ashley, You could try this plugin, http://wordpress.org...osts-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.

#8 jankowalski

jankowalski

    Advocate

  • Members
  • 344 posts
  • Country: Country Flag

Posted 30 October 2011 - 10:57 PM

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?

#9 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 30 October 2011 - 11:29 PM

@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.

#10 jankowalski

jankowalski

    Advocate

  • Members
  • 344 posts
  • Country: Country Flag

Posted 31 October 2011 - 11:34 AM

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.

#11 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 31 October 2011 - 12:32 PM

@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.

#12 jankowalski

jankowalski

    Advocate

  • Members
  • 344 posts
  • Country: Country Flag

Posted 31 October 2011 - 01:27 PM

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

#13 Danny

Danny

    Is Awesome!

  • Moderators
  • 13021 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 01 November 2011 - 08:04 AM

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

#14 jankowalski

jankowalski

    Advocate

  • Members
  • 344 posts
  • Country: Country Flag

Posted 01 November 2011 - 09:16 PM

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?