문제

I need to hook a post from Custom post type after every 5 posts from the main blog posts in the loop. Please suggest me with some code.

도움이 되었습니까?

해결책

May be there in no hook for that or i don't know about that, But You can do something like this:-

<?php
$postnum = 0; // Set counter to 0 outside the loop

if (have_posts()) : 
    while (have_posts()) : the_post();

        // Do regular stuff

        $postnum++; // Increment counter

        if ($postnum % 5 == 0){ // If the remainder of the counter value divided by 5 equals zero
            // Do special stuff
        }

    endwhile;
endif;
?>

Hope this will help you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top