custom post type and a “sticky” position taxonomy
custom post type and a “sticky” position taxonomy
custom post type and a “sticky” position taxonomy
It might just be the late hours, but the register_taxonomy call looks wrong. Shouldn’t the second parameter be the post type you’re registering the taxonomy for? I.e. array(‘pdsh_posts’). And yes, you need to register each of the three taxonomies separately for the post type. See the codex example, https://developer.wordpress.org/reference/functions/register_taxonomy/#comment-397 Edit Actually, its probably not what … Read more
ok – so this isn’t what I wanted but it does the trick. Adding a function to redirect when the user hits any term but one: function my_page_template_redirect() { if( is_singular( ‘custom-post-type’ ) && !(has_term(‘term’, ‘custom-taxonomy’)) ) { wp_redirect( home_url(), 301 ); exit(); } } add_action( ‘template_redirect’, ‘my_page_template_redirect’ ); Answer based on this one: Disable … Read more
Solution: I duplicated taxonomy.php template in theme folder and named it taxonomy-news-business.php then I edited the code inside this template So the result is that now all posts in CUSTOM POST TYPE with slug news with category businesss are displayed according this template because taxonomy template hierarchy in WordPress is taxonomy-{taxonomy}-{term}.php
update attribute of specific products in woocommerce
Add default custom taxonomy to plugin activation
What you need is to add a tax_query to your WP_Query arguments, where you check that your taxonomy exists on the posts you are querying. Here is an example that fetches the 3 latest published posts that have the taxonomy site set. $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ‘tax_query’ … Read more
In the scope of the code presented, $post is not defined. In order to use the $post global, you need to declare it as global beforehand (usually at the top of the function body which utilizes it): global $post; $id = $post->ID; That said, directly interacting with globals is generally discouraged as you’re often accessing … Read more
And here’s the answer to the issue : it was the fact that I named one of my custom taxonomy as year, which probably generated some issues in the query for static pages… Should have noticed that sooner, but hey, at least it’s fixed !
Custom post type paging return home page