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

Forcing oembeds to top of post

you can create custom post meta which contain youtube url and then $yt=get_post_meta($post->ID,’youtube_url’,true); if( ” != $yt) echo $GLOBALS[‘wp_embed’]->autoembed( $yt ); Updated: If i’m getting correctly then your content contain youtube url any where in it and you want to show them at top regardless there position in content. jut paste this code in functions.php … Read more

Display only deepest category on a single post?

I come to this post as i was looking for the code. But the marked answer not working for me anymore. I have wrote a function to get the deepest level category assigned to a post. function post_deepest_level_cat($post_categories) { foreach ($post_categories as $category) { $cat_ids[] = $category->term_id; } $tree_args = array( ‘current_category’ => $cat_ids, ‘depth’ … Read more

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