2017-12-17 12 views
0

아래의 코드는 5 번째 게시물 이후에 광고 배너를 삽입하는 데 사용됩니다. 1 번째와 5 번째 게시물 뒤에 배너를 삽입하고 싶지만 작동하도록 코드를 수정하는 방법을 모릅니다. 내가 필요한 것 때문에.WordPress 보관함에 광고 삽입

<?php 
function insert_between_posts($post) { 
    global $wp_query; 

    // Check if we're in the main loop 
    if ($wp_query->post != $post) 
     return; 

    // Check if we're at the right position 
    if (5 != $wp_query->current_post) 
     return; 

    // Display the banner 
    echo ' 
    <div banner>BANNER</div> 
    '; 
    } 
    add_action('the_post', 'insert_between_posts'); 
    ?> 

답변

0

if (5 != $wp_query->current_post) 

로 변경하려고 했

if (5 % $wp_query->current_post == 0 || 1 != $wp_query->current_post) 
매번 "current_post을"배너를 표시 할 것입니다 내 코드는 5의 배수, 또는 1

동일