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

Rewrite query var on postname

So, first up, I don’t believe that you need a rewrite tag in this situation, so you can omit that. The issue, I believe, with the remaining code is that your rewrite rule is only capturing 1 match (because there’s only one set of ()), so subpage isn’t receiving a value. Additionally, your rule seems … Read more

Theme customisation – how to store javascript externally when it utilises php variables?

Since it’s a plugin, you should enqueue jQuery first. Inside your add_action(‘wp_head’, function () { before wp_register_script( ‘custom_script’, get_stylesheet_directory_uri() . ‘/custom.js’ ); add : if ( ! wp_script_is( ‘jquery’, ‘enqueued’ )) { //Enqueue jQuery wp_enqueue_script( ‘jquery’ ); } This will check if jQuery is loaded and if not it will load it. Then, in your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)