How to fix a double slash in custom permalinks with hierarchical taxonomy’s?

There is a quick and somewhat dirty potential solution to this. I say ‘potential’ because I can’t spot the problem by looking at the code. I only have my suspicions. Instead of passing a separator like that. Try trailingslashit. } else $chain .= trailingslashit($name); return $chain; I am guessing at where the problem is based … Read more

Display CPT taxonomies as an archive page

You’re describing the default behaviour. Based on your code, you will have the following URLs: https://www.url.com/blog/addresses/ The archive of all Articles. https://www.url.com/blog/city/tunis/ The archive of all Articles assigned to the Tunis City. https://www.url.com/blog/addresses/article-title/ The single Article. If any of these URLs are returning a 404, you likely just need to flush your permalinks. This needs … Read more

How to show term-specific post list, without posts associated with child terms?

As @Milo’s pointer said, this: Sadly, is normal WordPress behaviour. Can be suppressed using parse_tax_query and include_children set at 0… The code found in the answer at https://wordpress.stackexchange.com/a/202773/39300 Works for me… function taxonomy_archive_exclude_children($query){ $taxonomy_slugs = [‘product_category’, ‘application_category’]; if($query->is_main_query() && is_tax($taxonomy_slugs)){ foreach($query->tax_query->queries as &$tax_query_item){ if(empty($taxonomy_slugs) || in_array($tax_query_item[‘taxonomy’], $taxonomy_slugs)){ $tax_query_item[‘include_children’] = 0; } } } } add_action(‘parse_tax_query’, … Read more

Order custom posts by taxonomy?

I believe you need a tax_query like the following from the Codex: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’ ) ) ); $query = new WP_Query( $args ); In your case that would look something like: $args = array( ‘post_type’ => ‘books’, ‘tax_query’ … Read more

How to make a list of companies’ information and display them to user, using custom post types and a custom taxonomy?

Custom post types and taxonomies are the appropriate method of doing this. It sounds like you’ve already identified the appropriate taxonomies and CPT: A company post type A company_type taxonomy register_post_type and register_taxonomy can do this for you. Don’t forget to re-save permalinks if you use those functions or change their parameters. After doing this, … Read more