Get list of all Topics in use by a custom post type

I think I cracked it actually! Used this snippet: <?php $custom_terms = get_terms(‘topic’); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array(‘post_type’ => ‘episodes’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘topic’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug, ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { echo ‘<h2>’.$custom_term->name.'</h2>’; } } ?>

How to include a query_vars value in document_title_parts?

If your query var tags is registered properly then the following code snippet will definitely work, I’ve tested it. It’s a modified version of your code snippet. Please make sure to add the code to your functions.php file. function prefix_custom_title($title_parts) { global $wp_query; if (isset($wp_query->query_vars[‘tags’])) { $title_parts[‘title’] = $wp_query->query_vars[‘tags’]; } return $title_parts; } add_filter( ‘document_title_parts’, … Read more

Custom permalink question

What you need is to register your own Rewrite Rule. To do it you should use add_rewrite_rule function. function my_custom_external_rewrite_rule() { add_rewrite_rule(‘^post-type-name/([^/]+)/?’, ‘index.php?page_id=<PAGE_ID>&external_page_name=$matches[1]’, ‘top’); } add_action( ‘init’, ‘my_custom_external_rewrite_rule’ ); And you’ll have to register your custom query variable (using query_vars hook): function my_custom_external_query_var( $query_vars ) { $query_vars[] = ‘external_page_name’; return $query_vars; } add_filter( ‘query_vars’, ‘my_custom_external_query_var’ … Read more