Replicating category/location page heirarchy

You can make CPT’s have “slugless” permalinks fairly easily: register_post_type( ‘service’, [ ‘hierarchical’ => true, ‘public’ => true, // Other args, no need for “rewrite” ]); // Change service to top-level permalink. add_permastruct( ‘service’, ‘%service%’, [ ‘with_front’ => false, ‘paged’ => false, ‘feed’ => false, ]); // Remove all default service rewrite rules. add_filter( ‘service_rewrite_rules’, … Read more

Changing CPT slug and taxonomy already registered in parent theme

WordPress 4.5 introduced the functions unregister_post_type() and unregister_taxonomy(). You could deregister your post type respectively taxonomy and register them again with your custom settings. The post type is still named portfolio. You could rename it, but you would probably have to check your template files for references. add_action(‘init’, ‘wpse_247924_overwrite_theme_post_types’, 1000); function wpse_247924_overwrite_theme_post_types() { unregister_post_type( ‘portfolio’ … Read more

List Top 5 taxonomy terms based on number of post

Here I’ve written a SQL query based function for you. You can use it to also for getting the top taxonomy terms based on post date range. Here it is- function the_dramatist_get_taxonomy_based_on_date_range_and_post_count( $args = array() ) { global $wpdb; $default_args = array( ‘taxonomy’ => ‘category’, ‘start_date’ => date(‘Y-m-d’), ‘end_date’ => date(‘Y-m-d’, strtotime(‘tomorrow’)), ); $args = … Read more

Print all the tags from a custom post type

To get the link of any term meta, use get_term_link() function. https://developer.wordpress.org/reference/functions/get_the_terms/ So replace the_permalink() to echo get_term_link($term->term_id); inside your loop. <a href=”https://wordpress.stackexchange.com/questions/248855/<?php echo get_term_link($term->term_id); ?>”><?php echo ‘<p>’ . $term->name . ‘</p>’;?> </a> This link will redirect to tag archive page. Hope this help!