How do I find a way to create a global single.php for a custom post type?

There re various filters you can use to inject your custom template. One being the template_include, the other single_template, and even type_template. The easiest one would be single_template in your case (example from codex): function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == ‘my_post_type’) { $single_template = dirname( __FILE__ ) . ‘/post-type-template.php’; } return $single_template; } … Read more

How to include any template using Shortcode fuction?

You can’t return the include statement. And you shouldn’t use include template parts. And here’s how to do it correctly: function custom_code() { ob_start(); get_template_part( ‘custom-template.php’ ); return ob_get_clean(); } add_shortcode( ‘custom_shortcode’, ‘custom_code’ ); So what we’re doing here is: Start output buffering. Include given template part using get_template_part function. Return all the output generated … Read more

How to display specific child page template in wordpress

Try this… Your code is hitting elseif(is_page() && $post->post_parent ) and stopping there. <?php if(has_children()){ // This is a parent page get_template_part(‘content’, ‘parent’); }elseif(is_page() && $post->post_parent ){ // This is a child page of certain parent page if(is_child_of(689)){ // This is a child page of Parent page having id 689 get_template_part(‘content’, ‘park’); }else{ get_template_part(‘content’, ‘child’); … Read more

Is it possible to access plugin data from a custom feed template?

The solution, for anyone else interested, was to clear cookies and the cache: clean_user_cache($current_user->ID); wp_clear_auth_cookie(); wp_set_current_user($current_user->ID); wp_set_auth_cookie($current_user->ID, true, false); update_user_caches($current_user); if( current_user_can( ‘mepr-active’, ‘memberships:1,2’ ) ) { echo ‘Hi ‘ . $current_user->user_login . ‘! You are a member’; } else { echo ‘Hi ‘ . $current_user->user_login . ‘! You <strong>not</strong> a member’; }

underscore template dynamically remove row Jquery

This isn’t WP related but Its not working because you are trying to add an event to a dynamically created element. Replace… jQuery( ‘.remove_field’ ).on(“click”, function(e){ e.preventDefault(); jQuery(this).parent(‘div’).remove(); }); With jQuery( ‘body’ ).on(“click”, ‘.remove_field’, function(e){ e.preventDefault(); jQuery(this).parent(‘div’).remove(); }); You can read more about your issue here.

Prevent 404 and serve custom template for custom URL

Got it! But this is a dirty thing. As it won’t take care of pagination and underlying queries. If you need a bit more of WordPress’ logic behind that custom route, please check the answer linked in the comments. But if you just need to serve one static page, this probably is a good starting … Read more

Assigning alternate single-{cpt} template based on blog_id in multisite

Actually, I noticed that your closure is not capturing/using the proper $template variable which is passed from the template_include filter hook: // This hook is defined in wp-includes/template-loader.php $template = apply_filters( ‘template_include’, $template ) The closure is also not returning the template.. So your closure should look like: add_filter( ‘template_include’, function( $template ) use ( … Read more