0

I am doing a theme with a 4x4 grid layout in Wordpress. I am planning to have the fourth block (1st column, 4th row) to display an ad. Can this be done in the post loop? The 4th block is not a post type, it will be and custom html div block.

4

1 回答 1

1

这将循环通过您的帖子,并且每第四次迭代,它将在帖子之前显示一个广告

$count = 1;
while (have_posts()) {
    if ($count % 4 > 0) {
        the_post();
    } else {
//display the ad
//put your ad code here
//then start a new row in your grid and display the post
        the_post();
    }
    $count++;
}
于 2013-08-16T02:24:01.823 回答