Use of Templates in a Plugin

You would need to add a filter to the page_template hook that will look for whatever criteria you need. For example, if your plugin was for a custom post type you would have something like this: function myCustomTemplate( $page_template ) { // Check theme for template file $located = locate_template( ‘single-{{postype}}’ ); if ( ! … Read more

Change title only in dynamic page

Just to make sure, does the title tag in your <head> area (presumably in header.php) look like this? <title><?php wp_title(); ?></title> It has to be like that for Yoast to work with it, and be able to override titles. Anyway if you add this to your single.php (or at least before get_header() is run for … Read more

How can I hardcode template selection?

First, let’s take a look at your code with some comments to show what’s happening. /** * Adds the function “set_templates” to the “template_include” filter with a * prioritiy of 99 (default is 10). * * What this means is that whenever WordPress runs the filter “template_link”, * your function “set_templates” will be called and … Read more

displaying category and subject posts

I’m not sure if I get you right, but if so, this will solve your problem: <?php $classes = array(); $subjects = get_the_terms( get_the_ID(), ‘subject’ ); $categories = get_the_terms( get_the_ID(), ‘category’); if ( count($terms) > 1 ) { $classes[] = “reset”; } else { foreach ($subjects as $term ) { $classes[] = $term->slug; } } … Read more