It sounds like you’re arriving at the archives for the tags, but the post type posts you set up aren’t shown in that archive.
I’d give this documentation page a readover and try out the code there.
https://docs.pluginize.com/article/17-post-types-in-category-tag-archives
If you need any help with that code, let me know.
Thank you for the answer! It works as expected. I have one question though, I have a custom field (using Advanced Custom Fields) in my custom post type called “Available”, how can I make only posts that have Available:yes appear on the archive? Because with that code all custom posts appear.
I figure I need to use something like this:
$query->query_vars[“meta_key”] = ‘available’;
$query->query_vars[“meta_value”] = ‘yes’;
And modify this part of the code:
$query->set(
‘post_type’,
array_merge(
array( ‘post’ ),
$cptui_post_types
)
);
but where exactly?
-
This reply was modified 5 years, 5 months ago by maddoctor.
If my previous experience tells me anything, I think you’d use the $query->set() method to set a meta_query parameter.
Similar to this from the WP_Query codex page:
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE',
),
),
);
$query = new WP_Query( $args );
You would do something like:
$query->set(
'meta_query',
array( array( 'key' => 'available', 'value' => 'yes' ) )
);
Worth a try at least 😀