WordPress:在自定义分类下拉菜单中添加一些选项

时间:2019-02-03 21:23:47

标签: wordpress custom-post-type

基于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>

0 个答案:

没有答案