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

Custom post type hierarchical loop in Homepage

From the look of your code, all you are doing is creating a nested list. If so, the easiest thing would be wp_list_pages. $args = array( ‘post_type’ => ‘cliente’, ‘post_status’ => ‘publish’, ‘author’ => $idutente, // must be comma separated list of IDs ); wp_list_pages($args); wp_list_pages only seems to work with ‘hierarchical’ => true,, but … 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

Control Loop Within Loop

I think you want something more like this: $args = array( ‘post_type’ => ‘testimony’, ); $testimony = new WP_Query($args); if ( have_posts() ) { while ( have_posts() ) { the_post(); if ( 0 !== $wp_query->current_post && 0 === $wp_query->current_post%3 && $testimony->have_posts() ) { $testimony->the_post(); echo ‘inner-loop’; the_title(); echo ‘inner-loop’; echo ‘<br>’; } wp_reset_postdata(); the_title(); echo … Read more

Create a custom taxonomy template that loops through child categories in term order?

Here’s what we’ve come up with so far, and there’s definitely room for improvement. remove_action( ‘genesis_loop’, ‘genesis_do_loop’ ); add_action( ‘genesis_loop’, ‘ahso_custom_taxonomy_archive_loop’ ); function ahso_custom_taxonomy_archive_loop() { global $wp_query; // globalize it. // get category ID $cat_id = $wp_query->get_queried_object_id(); // get current category // get all child categories $cat_args = array( ‘type’ => ‘products’, ‘child_of’ => $cat_id, … Read more

Output after specific post in the loop

Unfortunately there’s no purposely provided hook available for this. The only hooks inside the loop are triggered at the start and the end of the hook. There is the_post action, but this is probably far too generic to use (may cause undeseriable side effects) and is called a the wrong point for example: The function … Read more

WP_Query orderby random do not repeat infinite scroll – one loop

I use this solution in my functions.php /*—— order ——*/ session_start(); add_filter(‘posts_orderby’, ‘edit_posts_orderby’); function edit_posts_orderby($orderby_statement) { $seed = $_SESSION[“sem”]; if (empty($seed)) { $seed = rand(); $_SESSION[“sem”] = $seed; } $orderby_statement=”RAND(“.$seed.’)’; return $orderby_statement; } And additionaly, in the page where you show the posts, in the top of the file, i reset the session variable to … Read more