簡體   English   中英

ACF Wordpress按類別和自定義字段獲取帖子

[英]ACF Wordpress get posts by category and custom fields

我在Wordpress中遇到ACF問題。 我創建了自己的領域 在此處輸入圖片說明 並創建了自己的插件來顯示它,但是我不知道如何顯示所有字段。 現在我有這樣的事情:

   wp_reset_postdata();
   $myargs = array (
      'showposts' => 6
   );
   $myquery = new WP_Query($myargs);
     if($myquery->have_posts() ) :
       while($myquery->have_posts() ) : $myquery->the_post();
   ?>
   <p>
     <?php the_title(); ?>
   </p>
   <?php endwhile;
         endif;
         wp_reset_postdata();

這會顯示所有帖子。 我只想顯示類別“ Raporty”中的帖子,並且想顯示所有自定義字段。

對不起我的英語不好 ;)

西瑪·庫博

要顯示僅具有post_type'raporty'的帖子,請將其添加到$myargs

$myargs = array (
      'showposts' => 6,
      'post_type' => 'raporty'
   );

在wp循環中,您可以只使用例如get_field( 'typ_raportu' ) 外循環get_field( 'typ_raportu', post_id_here )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM