wordpressでアイキャッチを取得したいと思っています。
しかし不思議なことが起こっています!
■投稿画面は取得できない
→content-test.phpを[phpinclude file='content-test']で呼び出す場合。
■検索結果は取得できる
→search.phpを通してcontent-test.phpを呼び出す場合
のです!
2つのファイルはそれぞれ次のように書いてあります。
content-test.php
php
1 <ul> 2 <a href="http://example.com/"> 3 <?php 4 if ( has_post_thumbnail( 100 )) { 5 the_post_thumbnail(('full'), array( 'class' => 'cakeimage' )); 6 } 7 else { 8 echo '<img src="noimage.jpg">'; 9 } 10 ?> 11 </a> 12 </ul>
search.php
php
1<?php 2if ( have_posts() ) : 3 while ( have_posts() ) : 4 the_post(); 5 get_template_part( 'template-parts/content-test' ); 6 endwhile; 7 the_posts_pagination(); 8else : 9 get_template_part( 'template-parts/content-test', 'none' ); 10endif; 11?>
どうして検索結果のときはきちんと取得されるのに、[phpinclude file='content-test']で呼び出すと何も取得されないのでしょうか?
原因がお分かりになる方、いらっしゃいましたらご教示頂ければ幸いです。
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー