2013-08-16 21 views
0

我正在做一個WordPress的4x4網格佈局的主題。我計劃在第四欄(第一欄,第四欄)顯示廣告。這可以在後循環中完成嗎?第四塊不是帖子類型,它將是和自定義的html div塊。在Wordpress後循環顯示中插入廣告

回答

1

這將循環通過你的帖子,並每4個迭代,將後

$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++; 
} 
前右側顯示廣告