make diffrent template on last six post published

As written, you are checking the total post count against your counter. That is, $wp_query is the total post count for the query not the per page count. Now, assume 30 posts total in the query with 10 posts per page. Your counter starts and will get all the way to 10, but $ctr < … Read more

How to add a byline to all the pages?

You will do this in your theme and HOW you do it will depend on how your theme is set up. But to give a quick example, I’ll show you how to do it with any template with a loop. <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); echo (‘<p>This post … Read more

Where to add offset?

<?php $recent = new WP_Query( array( ‘tag’ => get_option(‘gd_slider_tags’), ‘posts_per_page’ => get_option(‘gd_slider_num’), ‘offset’ => 1) ); while($recent->have_posts()) : $recent->the_post();?>

Exceprt not displaying

According to your question: What is the main reason of loop? the clearest answer comes from official documentation: The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The … Read more

excerpt not showing up

Inside a template file, the standard loop syntax will display only the information about that page( In fact, a template file is no more than a page ). If you want to display some posts you need to run a custom query or to include ( get_template_part() ) another template file which normally runs a … Read more

Show terms in archive page

get_terms() retrieves terms in general, it makes no connection to a current post in loop. What you need is one of template tags, which retrieve terms for the post. For example the_terms(): while (have_posts()) : the_post(); the_terms( get_the_ID(), ‘event_cat’ ); endwhile; There are quite a few functions dealing with terms, depending on what you want … Read more

Accessing the Posts page Content

So you can fetch the id using a get_option call, then access the data from there. $page_for_posts = get_option( ‘page_for_posts’ ); $page_data = get_page( $page_for_posts ) ; Then you can access the properties like this: <?= get_the_post_thumbnail($page_data->ID) ?> <h1><?= $page_data->post_title ?></h1> <?= $page_data->post_content ?>

Reset Loop get_posts();

$posts is a global var used by WordPress, change that to something unique and it’ll work as expected. Also fyi, rewind_posts(); isn’t necessary here, you haven’t run the loop yet, so there’s nothing to rewind.