![]() |
Custom Post Type categories
Hello all,
I know this is going to fall outside of general support, but I'm hoping the community can help me figure this out. I have added custom post types to a site and I'm having trouble with the categories. I have a category with only posts from my custom post types selected with it. If you select categories in the Wordpress admin, you can see that the category has the right number of posts associated with it. If you click that number to reveal the post, the page shows no post in that category. The same is true if you go to the front end and look at the category archive page for that category. Here is the code for the cpt. PHP Code:
Thank you, Keith |
Travis has a full series on working with custom post types and Genesis over here:
http://wpsmith.net/category/custom-post-types/ |
Great, thanks. Looks like I have some reading to do. While I'm sifting through this, if anyone has an idea or solution, please chime in. At first glance I don't see my answer easily found in Travis' posts. I know it's in there, but it may require a lot of code altering to match his in an effort to figure it out. I feel like I'm just missing one piece of the puzzle, since I can see the post associated with the category in the post count on the category admin page.
Thanks again, Keith |
I think the problem is that normal archives for categories or tags don't include CPT's, so you have to add them. But just adding them to the filter can break custom menus. The code below adds CPT's to category or tag archives and accounts for custom menus.
Note, you have to change yourcustomposttype to your CPT, which in your case is schedule. PHP Code:
|
Bill - I have been thinking about this today and thought the problem involved the archives not recognizing my cpt. I'll try your code and see how it works and let you guys know. I really appreciate your time responding and helping me out.
Have a great day. Keith |
Well, I suppose I've spent to much time behind the computer today, because I drawing a blank as to where to use this code. I tried writing it in the functions file and the archive page of the child theme (minimum). Any chance someone could hold my hand further, as I'm having a brain fart?
Thanks, Keith |
It goes in the functions.php file of your child theme if that is where your CPT is registered. Otherwise, you can put it in the file that registers your CPT. I recommend putting it after the registration code.
I pasted that code from a working site, where I grabbed it from functions.php, where the CPT is registered just before, so that does work. Post back with more details if that doesn't and I'll try to help. |
Bill, that did it. Not sure why I couldn't get it to work the first time I put it in the functions file. I was probably just over thinking it.
Thank you so much for your time, Keith |
| All times are GMT -5. The time now is 04:45 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.