基于Wordpress Codex,我创建了具有自定义帖子分类法的下拉菜单。它可以正常工作,但是我需要在顶部添加自定义位置,并带有指向特定页面或存档页面的链接。甚至有可能吗?
<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get">
<?php $args = array(
'show_option_all' => __( 'Wybierz album' ),
'option_none_value' => '-1',
'orderby' => 'name',
'order' => 'ASC',
'show_count' => 1,
'echo' => 0,
'selected' => 1,
'hierarchical' => 1,
'name' => 'albums',
'class' => 'postform',
'taxonomy' => 'albums',
'value_field' => 'slug',
); ?>
<?php $select = wp_dropdown_categories( $args ); ?>
<?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?>
<?php $select = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?>
<?php echo $select; ?>
<noscript>
<input type="submit" value="View" />
</noscript>
</form>