Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何显示自定义post';在没有链接和回显的循环中选择了什么自定义分类法?_Php_Wordpress_Custom Taxonomy - Fatal编程技术网

Php 如何显示自定义post';在没有链接和回显的循环中选择了什么自定义分类法?

Php 如何显示自定义post';在没有链接和回显的循环中选择了什么自定义分类法?,php,wordpress,custom-taxonomy,Php,Wordpress,Custom Taxonomy,下面是我试图整理的代码片段: $args=array( 'post_type' => 'custom_post_type', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_key' => 'custom_meta_key', 'meta_value' => 'on', ); $my_query

下面是我试图整理的代码片段:

$args=array(
      'post_type' => 'custom_post_type',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'meta_key'         => 'custom_meta_key',
      'meta_value'       => 'on',
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    while ( $my_query->have_posts() ) : $my_query->the_post();
        $custom_taxonomy = the_terms( $post->ID, 'custom_taxonomy');
    endwhile;
然而,这也引起了共鸣

<a rel="tag" href="http://myweb/custom_taxonomy/selectedTerm/">selectedTerm</a>

但我只需要
selectedTerm


使用
strip\u tags()
没有帮助,因为
术语()
正在回显链接。

您将希望使用
获取术语($post->ID,'custom\u taxonomy')
而不是
术语()

这将返回一个术语对象数组。您可以通过执行以下操作访问术语名称:

while ( $my_query->have_posts() ) : $my_query->the_post();
    $custom_taxonomy = the_terms( $post->ID, 'custom_taxonomy');
endwhile;

// Print the term names
foreach ( $custom_taxonomy as $term ) {
  echo $term->name;
}

查看法典以了解更多关于

的信息,我只是通过核心进行了歌舞表演,并发现了这一点。但是我必须使用
$custom\u taxonomy=array\u shift($custom\u taxonomy)没有foreach循环,因为我一次只使用一个分类法