Looping single post in a theme

Firstly, you don’t need to check with is_single() in single.php. WordPress will automatically recognize it for single post. Secondly, breakdown your template with in parts. Such as break your main loop code in content-single.php and call it in single.php with get_template_part(‘content’, ‘single’). So you single.php template will look like below- <?php while ( have_posts() ) … Read more

How to return a blank page

To return a blank page that’s been created in a plugin like so: Example: blank-page.php <?php // Blank PHP page… Use the following function: add_filter( ‘some_tag’, ‘wpse_238008_blank_page’, 99 ); function wpse_238008_blank_page() { // Template with an empty page define( ‘PLUGIN_PATH’, plugin_dir_path( __FILE__ ) ); return PLUGIN_PATH . ‘/path/to/blank-page.php’; } Replace the following to suit your … Read more

Query only title/field/featured media of posts [closed]

You can make query like this $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, //Specyfying post type ‘cat’=> 1, //Selecting post category by ID to show ‘posts_per_page’ => 10, //No. of posts to show ‘paged’ => $paged //For pagination ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) … Read more