【问题标题】:Display Custom Taxonomy & Meta Field显示自定义分类和元字段
【发布时间】:2013-02-14 03:10:14
【问题描述】:

我正在尝试基于自定义帖子类型的自定义分类构建一个滑块。自定义帖子是产品,分类是类型。

我已经成功地让分类法正确显示,但我无法让我添加的自定义元字段显示。

我的工作分类显示代码如下,我想获取元字段(称为块图标)以显示在

希望这是有道理的,有人可以提供帮助。谢谢!

<div id="slider"><?php
        $args = array( 'taxonomy' => 'type' ); $types = get_terms('type', $args);
        $count = count($types); $i=0;
        if ($count > 0) {
            foreach ($types as $type) {
                $i++;
                $type_list .= '<div class="slider-' . $type->slug . ' container">';
                $type_list .= '<div class="slider-text divider">';
                $type_list .= '<i class="aspera-icon lrg">a</i>';
                $type_list .= '<h1>' . $type->name . '</h1>';
                $type_list .= '<h5>' . $type->description .'</h5>';
                $type_list .= '</div>';
                $type_list .= '</div>';
            }
        echo $type_list;
        }   
    ?>
</div>

【问题讨论】:

    标签: wordpress


    【解决方案1】:
    <?php
    $args = array(
        'tax_query' => array(
            array(
                'taxonomy' => 'sliders_category',
                'field' => 'id',
                'terms' => '5'
            )
    ),
    'post_type'=>'sliders',
    'order'=>'ASC',
    'posts_per_page'=>-1
    );
    query_posts($args);
        while ( have_posts() ) : the_post(); 
    ?>
        <?php the_title();?>
        <?php the_content(); ?>
        <?php 
        endwhile; 
        wp_reset_query();
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-06
      • 1970-01-01
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-14
      • 1970-01-01
      相关资源
      最近更新 更多