我正在構建一個主題,但不懂php的我很容易出現語法錯誤。 我創建了這個回圈,以顯示一個名為"disturbo"的自定義帖子型別的所有帖子。我想顯示標題、縮略圖和一個名為"citazione"的自定義欄位,其中有一個標語/引語。
我得到了一個錯誤
。"語法錯誤,意外的標記 "endif",期待檔案的結束"
我的代碼有什么問題?
我有什么問題? <?php $args =array(
'post_type'/span> => 'disturbo'/span>,
'category_name' => 'disturbo' 。
'orderby' => 'title' 。
'order' => 'desc'。
'post_per_page' => -1 )。)
? >
<?php $disturbohome = new WP_Query($args); ?>/span>
<?php if ( $disturbohome-> have_posts() ) :
while ( $disturbohome-> have_posts() ) 。
$disturbohome->the_post(); ? >
<li>
<a class="flex" href="<?php get_permalink(); ? > ">
<? php the_post_thumbnail( 'full' , ['class' => 'img-terapia'] ) ; ? >
<div>
<? php the_title( ' < h4 class="bluetext">', '</h4>' ); ? >
<p class="tagline bluetext" ><? php if ( get_post_meta( get_the_ID), 'citazione', true ) : ? ) : ?>
<p class="tagline bluetext">< ? php echo ( get_post_meta( get_the_ID( ) 。'citazione', true ) ); ?>
<?php endif; ?>
</p>
<a href="<?php get_permalink(); ? >" class="more">learn more</a>
</a>
</li>
<?php endif; ?>
<? php endwhile; // end of the loop. ?">
<?php wp_reset_postdata(); ?>
</ul>
</nav>
</div><! --- FINE DIV CENTER-->
uj5u.com熱心網友回復:
你錯誤地嵌套了while回圈。 while回圈的開始和結束需要 "嵌套 "在if條件里面。
<?php $args = array (
'post_type'/span> => 'disturbo'/span>,
'category_name' => 'disturbo' ,
'orderby' => 'title' 。
'order' => 'desc'。
'post_per_page' => -1 )。)
? >
<?php $disturbohome = new WP_Query($args); ?>/span>
<?php if ( $disturbohome-> have_posts() ) :
while ( $disturbohome-> have_posts() ) 。
$disturbohome->the_post(); ? >
<li>
<a class="flex" href="<?php get_permalink(); ? > ">
<? php the_post_thumbnail( 'full' , ['class' => 'img-terapia'] ) ; ? >
<div>
<? php the_title( ' < h4 class="bluetext">', '</h4>' ); ? >
<p class="tagline bluetext" ><? php if ( get_post_meta( get_the_ID), 'citazione', true ) : ? ) : ?>
<p class="tagline bluetext">< ? php echo ( get_post_meta( get_the_ID( ) 。'citazione', true ) ); ?>
<?php endif; ?>
</p>
<a href="<?php get_permalink(); ? >" class="more">learn more</a>
</a>
</li>
<? php endwhile; // end of the loop. ?">
<?php endif; ?>
<?php wp_reset_postdata(); ? >
</ul>
</nav>
</div><! --- FINE DIV CENTER-->
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/309992.html
標籤:
上一篇:如果找到一個特定的值,如何將一個資料框架行追加到一個串列中?
下一篇:WhileTrue和條件陳述句
