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');
?>