Change site template from php

If I understand your question, you should use this inside your foreach: $argument_to_pass_to_switch_theme = $theme->get_stylesheet(); Just taking a look at the documentation: The function wp_get_themes()… “…returns an array of WP_Theme objects based on the argument.” This class WP_Theme has a method get_stylesheet(), which… “…returns a string with the directory name of the theme’s “stylesheet” files, … Read more

Load template inside a parent template

if ( condition ) { get_template_part( ‘path/to/template’, ‘mobile’ ); } else { get_template_part( ‘template’, ‘mobile’ ); // in rootpath } You can also intercept the behavior for get_template_part() with an action hook: // Source in get_template_part do_action( “get_template_part_{$slug}”, $slug, $name ); function wpse21352_template_part_cb( $slug, $name ) { switch ( $name ) { case ‘mobile’ : … Read more

Create a WordPress template without navigation and footer

Don’t remove get_header(). Duplicate the header.php to header-{custom-name}.php, let’s say (header-nonavfooter.php) then in the template file replace get_header() with get_header(‘nonavfooter’). In the new header file (header-nonavfooter.php) remove the code related to navigation. Do the same for the footer.php also(Create a new footer.php and remove the footer parts that you don’t need), remember not to remove … Read more

Make Custom Taxonomy Category Use Parent Template

Hook into template_include filter add_filter(‘template_include’, ‘research_term_template’); function research_term_template( $template ) { if ( is_tax(‘classifications’) ) { $parent = get_term_by(‘slug’, ‘oldresearch’, ‘classifications’); // to improve performance you can hardcoding ‘oldresearch’ term id // $parent = 12; if ( term_is_ancestor_of( $parent, get_queried_object(), ‘classifications’ ) ) return get_template_directory() . ‘/taxonomy-Classifications-oldresearch.php’; } return $template; }

How to retrieve depth of menu into template

how to get the relation between the page and the menu item ? = is there a WP function telling this page is linked to this menu item which has or hasn’t a parent Inside the walker, inside the start_el method (which you mentioned), $item->object_id is the page ID. Otherwise, you need to pull the … Read more

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