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

Prevent private post 404

According to the Content Visibility page, Private posts are visible only to those with sufficient permission levels. WordPress doesn’t expose them to non-logged-in users at all, hence (presumably) the 404. If you want to display a limited preview to non-members, instead of setting the post to Private, you could try something like this: add_filter( ‘the_content’, … Read more

Modifying searchform.php and search.php to have two kinds of searches

For anyone trying to achieve something similar, here’s how I solved it: In searchform.php, duplicate the form, as such: <form method=”get” id=”searchform” action=”<?php echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); ?>”> <input type=”text” name=”s” id=”s” placeholder=”<?php esc_attr_e( ‘Search by Post’ ); ?>” /> <input type=”hidden” name=”search-type” value=”posts” /> <button type=”submit” name=”submit” id=”searchsubmit” value=”<?php esc_attr_e( ‘Search’ ); … Read more

Stream Video Player does not work with do_shortcode()?

It’s not really a shortcode, its a content filter but you can try calling the plugins function directly: if (function_exists(‘StreamVideo_Parse_content’)){ echo StreamVideo_Parse_content(“[stream flv=xxx.es/wp-content/uploads/2011/04/VIDEO-UE.mp4 mp4=xxx.es/wp-content/uploads/2011/04/VIDEO-UE.mp4 provider=video img=xxx.es/wp-content/uploads/2011/04/previo-video.jpg embed=false share=false width=500 height=333 dock=true controlbar=over bandwidth=high autostart=false opfix=true /]”); }

How to show scaled featured image in template?

You can create custom size image with add_image_size() in the functions.php function add_custom_size_images() { // Add image size width 300 with unlimited height. add_image_size( ‘featured-image-300’, 300 ); } add_action( ‘after_setup_theme’, ‘add_custom_size_images’ ); And in the template to get the size that you created with the_post_thumbnail() the_post_thumbnail( ‘featured-image-300’ ); Notice: If you want it to work … Read more