Thread Starter
dan
(@daniel-berhane)
One more thing: Is it possible to subscribe (via rssfeed or email) to a single CPT posts archive(example.com/cpt-name/feed/)?
Hey Dan,
1. You have to create custom taxonomy (in other words custom categories) for your post type. CPT cannot be assigned to default taxonomy such as post categories.
2. If for example your CTP is called “portfolio”, then you have to create a “archive-portfolio.php” file into your theme directory. Just copy the source from the default archive.php/index.php file and make the changes you have in mind.
3. In my experience, it all depends of how popular your site is. The main problem with the pretty permalinks is that they make your website slower. If you don’t have big traffic you normally won’t need to worry about that. However, you should be able at least to add an ID to your permalinks.
4. Yep, http://example.com/feed/?post_type=cpt-name
Niki
Thread Starter
dan
(@daniel-berhane)
Thank you very much for your help.
However, I am confused on one point.
*You said:
“CPT cannot be assigned to default taxonomy”.
Did you mean I shouldn’t? or a bad idea?
Because, if you create a CPT using “Custom Post Type UI version: 0.8.2”, there is “Advanced Options” – “Built-in Taxonomies”.
It lets you decide to enable the default categories and tags for CPT.
Thank you again.
Hey,
No worries.
As for #1, I misunderstood your question at first, so your confusion is actually my fault 🙂 Yes, you can do that, it’s not a bad idea, neither bad practice.
Best,
Niki
Thread Starter
dan
(@daniel-berhane)
Thanx.
Then, how do I make the CPT posts show up on the archive page of the default category?
For example: I wrote a post and published it in a CPT and assigned it to a custom taxonomy called “painting” and also to a default category called “art”.
The post can be found on:
* example.com/CPT-name/
* example.com/custom_taxonomy/painting
However, it is not visible on example.com/category/art
How do I fix that?
In order to fix that, you have to edit your theme’s category.php file. If there’s no such file, then you have to edit archive.php or index.php if there also isn’t archive.php one.
Find the following (or something similar to it):
while ( have_posts() ) : the_post();
and just before that line add the following piece:
global $wp_query;
$custom_args = array(
'post_type' => array( 'post', 'your-custom-post-type' )
);
query_posts( array_merge( $wp_query->query_vars, $custom_args ) );
Hope that helps,
Niki
Thread Starter
dan
(@daniel-berhane)
I will try that and get back to you/this thread ASAP.
Thank you for your kindness.
Thread Starter
dan
(@daniel-berhane)
Hello Koliu,
I been trying the codes you gave me in the index.php (I am using theme piboard and in the wp-includes directory there is no category.php and archive.php.)
global $wp_query;
$custom_args = array(
'post_type' => array( 'post', 'your-custom-post-type' )
);
query_posts( array_merge( $wp_query->query_vars, $custom_args ) );
However, it is not working for me.
When I add it into the index.php, I see the codes themselves on the front page AND the category page don’t display my CPTs.
Is there is something I should have added above or below the codes?
[Alternatively, can you give me a code I can use in the functions.php? For example, I added a simple code in the fnctions.php and it let me display CPTs in the home page without ado.]