How to Handle CSS for Multiple Header header.php Files?

That’s not how you use get_theme_file_uri(); You need to specify the directory RELATIVE to your currently active theme’s directory. So for example, if your currently activated theme is rm-acf1, and all of your custom header CSS files are located in the subfolder hdr-styles. This is your theme directory: ./wp-content/rm-acf1/ This is your header styles directory: … Read more

How do I set a specific template for sub-categories?

I would recommend using the category_template filter – just check if the current category is an ancestor of 67: function wpse_179617_category_template( $template ) { if ( cat_is_ancestor_of( 67, get_queried_object_id() /* The current category ID */ ) ) $template = locate_template( ‘category-slider.php’ ); return $template; } add_filter( ‘category_template’, ‘wpse_179617_category_template’ );

A shared custom taxonomy between two custom post types

You use get_query_var(‘post_type’) to set the post type in your args array $args[‘post_type’] = get_query_var(‘post_type’); and also include the right loop part based on that for example: if (get_query_var(‘post_type’) == “event”){ get_template_part( ‘loop’, ‘event’ ); }else{ get_template_part( ‘loop’, ‘other’ ); }

Best approach for loading a sidebar Only if the screen max-width is >900px?

On my website I load the recent comments per AJAX for window sizes above 480px: if ( 480 < jQuery(window).width() ) { jQuery(document).ready( function() { jQuery.get(‘http://toscho.de/?rc’, function(data) { jQuery(data).insertBefore(‘#inner’); } ); } ); jQuery(‘#posts’).after(‘<div class=clear>&#160;</div>’); } This code is quite old and not very elegant. But it may give you a hint for the right … Read more

On Taxonomy Template page, want to add Post_Type

You can use pre_get_posts filter hook to check if you are on the taxonomy page and if so just add your custom post type to the query something like this: function add_my_type( $query ) { if ( $query->is_tax(‘YOUR_TAXONOMY’) ) { $query->set( ‘post_type’, array(‘post’,’YOUR_CUSTOM_POST’) ); } } add_filter( ‘pre_get_posts’, ‘add_my_type’ );

wordpress – load a template based on the URI

I assume that your custom post type windows would map onto /windows/ etc? You can customise the template for individual custom post types via single-posttype.php in your theme, e.g. single-windows.php single-doors.php and single-garages.php WordPress will automatically pick these up You could also use custom page templates, e.g. page-windows.php or custom templates with the right template … Read more

How to assign a class to a page with a custom template?

Using is_page(8) will make your code a bit static. Let’s make it dynamic as you’re after with is_page_template(): <?php function prefix_conditional_body_class( $classes ) { if( is_page_template(‘mytemplate.php’) ) $classes[] = ‘mytemplate’; return $classes; } add_filter( ‘body_class’, ‘prefix_conditional_body_class’ ); Worked for me in a child theme with the template file in the root of the child theme, … Read more