【问题标题】:ACF Wordpress get posts by category and custom fieldsACF Wordpress 按类别和自定义字段获取帖子
【发布时间】:2016-09-23 03:39:05
【问题描述】:

我在 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”类别的帖子,并且我想显示我的所有自定义字段。

对不起我的英语;)

【问题讨论】:

  • 我问是因为我想确定...类别“Raporty” - 它是分类法还是自定义帖子类型?

标签: php wordpress


【解决方案1】:

西玛库博尔,

要仅显示带有 post_type 'raporty' 的帖子,请将其添加到 $myargs

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-25
    • 2021-07-22
    • 2021-11-30
    • 1970-01-01
    • 2014-03-02
    • 2012-05-17
    • 1970-01-01
    • 2021-01-09
    相关资源
    最近更新 更多