Custom Post Type Categories URL not displaying posts

You are specifying the same slug of destinations for both your custom post type and for your taxonomy, unfortunately by default this doesn’t behave how you’d expect due to WordPress’ rewrite API. Which caters for the default nature of posts, archives, taxonomies, slugs and the WordPress template hierarchy. If this URL structure is not important … Read more

Get parent category(taxonomy) ID from single template of a custom post type

Get Object Terms : Retrieves an array of WP_Term object associated with the given post, in the supplied taxonomies. Term object ( WP_Term )offers some handy information. For example, Gives you term slug: e.g.: term-slug-example $slug = $term->slug; Gives you term name: e.g. Term Name Example $name = $term->name; Gives you term description: e.g. This … Read more

How to display hierarchical and non-hierarchical taxonomies?

At the beginning, get taxonomies registered for a given type of post with get_object_taxonomies(). Then check which ones are hierarchical, e.g. using is_taxonomy_hierarchical() conditional tag. The last step is to display the lists. // current post ID $post_id = get_the_ID(); // taxonomies registered for this type of posts $taxonomies = get_object_taxonomies( get_post_type() ); $taxs_tree = … Read more

WordPress hook which triggers on post import

If you are trying to fire your function when the WordPress Importer runs, there are a few filters and action hooks available. From the plugin documentation: import_start: occurs after the export file has been uploaded and author import settings have been chosen import_end: called after the last output from the importer https://wordpress.org/plugins/wordpress-importer/

Use the custom post type archive for taxonomies?

You can create taxonomy-cat-cpt.php, and inside it just use: <?php get_template_part( ‘archive-cpt’ ); ?> Then they’ll both use the same template. Then inside archive-cpt.php, if you use the_archive_title() archive the_archive_description() it will display the appropriate title and description automatically based on whether you’re viewing the taxonomy or post type archive. Regarding posts, as long as … Read more