Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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
Wordpress将分类显示为下拉菜单_Wordpress_Taxonomy - Fatal编程技术网

Wordpress将分类显示为下拉菜单

Wordpress将分类显示为下拉菜单,wordpress,taxonomy,Wordpress,Taxonomy,我已经建立了一个层次分类法,在管理员界面中显示可用香水的主列表。创建页面时,选中可用于该特定页面的香水。我将此代码用于functions.php,它似乎在管理中起作用: add_action( 'init', 'build_taxonomies', 0 ); function build_taxonomies() { register_taxonomy( 'scents', 'page', array( 'hierarchical' => true, 'label' => 'Sce

我已经建立了一个层次分类法,在管理员界面中显示可用香水的主列表。创建页面时,选中可用于该特定页面的香水。我将此代码用于functions.php,它似乎在管理中起作用:

add_action( 'init', 'build_taxonomies', 0 );

function build_taxonomies() {
register_taxonomy(
'scents',
'page',
array( 'hierarchical' => true,
'label' => 'Scents',
'query_var' => true,
'rewrite' => true ) );
}
现在我需要输出选中标记的项目,以便它们以下拉菜单的形式显示在页面上

问题是,它输出所有页面上已被选中标记的所有气味。我只需要它输出那些已经在你的页面上被选中标记的内容

以下是我使用的代码:

<?php wp_dropdown_categories('taxonomy=scents'); ?>


我如何编辑它,使其只显示我所在页面的香味?谢谢。

您需要类似于
wp\u get\u object\u术语($post->ID,'scents')


请在:

处核对文件,你能举例说明吗?我看了文档,但没用。谢谢。例如:函数get_-marked_-scents($postid=null){if(is_-null($postid)){//如果没有定义$postid,让我们使用全局$post->ID全局$post;$postid=$post->ID;}/'scents'是分类法slug$scents=wp_-get_对象术语($postid,'scents');if(!is_-wp_-error($scents)&&!empty($scents)){foreach($scents as$scents){//build dropdown here}}}。。。对不起,我花了这么长时间