Changing layout programmatically
Changing layout programmatically
Changing layout programmatically
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
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
Define it in functions.php, which is loaded on every request. However, there are far better options than a global variable: a function a template part if it’s a template you’re defining filters
Your best bet is to rename the old header.php to header.bak.php and your new copy to header.php. header.php (there’s only one such file, always) is called from the other theme templates using get_header(). What you could/eventually should do, if you don’t want to directly edit the existing theme, is set up a child theme, copy … Read more
You can not replace half of a template by using filters and hooks if the template itself doesn’t support so. The template_include will override an entire template, it means header, body, content, sidebar, footer, and everything. Now you have these options: Style Your Template Create a full single-my_member.php file and then style it by CSS … Read more
Advanced Custom Field DatePicker [closed]
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
You do not need to explicitly call the post-single template, this is something wordpress is doing automagically for you based on the URL structure. For archive URLs the archive template will be “called” while for single posts the single template will be “called. There are fullbacks with the ultimate one is the index.php template. For … Read more
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