関連記事にアドセンスを表示するには!

関連記事にアドセンスを表示するには、「related-posts.php」に追記が必要です。

 


〜
<h3 class="sub-title">関連コンテンツ</h3>
<div id="related-posts">
<?php $posts=get_posts('category='.$category_id.'&numberposts=5&orderby=rand&exclude='.$post->ID); ?>
<?php $count = 1; if($posts):foreach($posts as $post):setup_postdata($post); ?>

<!-- ここに挿入します! -->

<article>
<?php  if ( has_post_thumbnail() ): ?> 
  <div class="img-set"> <a href="<?php the_permalink() ?>" class="link"><?php the_post_thumbnail( ); ?></a></div>
<?php endif; ?>
  <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>

〜

 
 

広告5のウィジェット領域を利用する

下記の広告ウィジェットを表示させる領域を、上記の部分に挿入して下さい。


<?php if($count === 2): ?>
<article>
  <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('広告05') ) : ?>
  <?php endif; ?>
</article>
<?php endif; ?>

 
 

Advanced Adsプラグインを利用する

「Advanced Adsプラグイン」プラグインで、下記の様にアドセンスを設定します。
 

 
上記の <?php the_ad(1213); ?> を利用します。

 
次の部分を追記して下さい。


<?php if($count === 2): ?>
<article>
  <?php the_ad(1213); ?>
</article>
<?php endif; ?>

 
ただし、「Custon HTMLウィジェット」にショートコード、例えば [the_ad id=”1213″] を記述して、上記の方法を利用することもできます。

 
 

HOME


関連コンテンツ


コメントはお気軽にどうぞ

メールアドレスは公開されません。
また、* が付いている欄は必須項目ですので、必ずご記入をお願いします。

内容に問題なければ、下記の「コメントを送信する」ボタンを押してください。