首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >帮助理解WordPress下拉列表代码

帮助理解WordPress下拉列表代码
EN

Stack Overflow用户
提问于 2016-08-11 17:51:34
回答 1查看 57关注 0票数 0

我被要求在wordpress中创建一个新的下拉菜单。我从来没有用过word press,我也从来没有用php写过代码。我设法为现有的下拉菜单找到了一段代码,但我不明白它是如何工作的。我希望有人能帮我解释一下,这样我就能对发生的事情有所了解了。

代码语言:javascript
运行
复制
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
    <tr class="form-field term-parent-wrap">
        <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
        <td>
            <?php
            $dropdown_args = array(
                'hide_empty'       => 0,
                'hide_if_empty'    => false,
                'taxonomy'         => $taxonomy,
                'name'             => 'parent',
                'orderby'          => 'name',
                'selected'         => $tag->parent,
                'exclude_tree'     => $tag->term_id,
                'hierarchical'     => true,
                'show_option_none' => __( 'None' ),
            );

            /** This filter is documented in wp-admin/edit-tags.php */
            $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
            wp_dropdown_categories( $dropdown_args ); ?>
            <?php if ( 'category' == $taxonomy ) : ?>
            <p class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
            <?php endif; ?>
        </td>
    </tr>

谢谢

EN

回答 1

Stack Overflow用户

发布于 2016-08-11 17:54:38

首先,告诉我们你在寻找什么样的下拉列表。WHat你想在下拉菜单中有吗?因为您的代码当前设置为显示指向您的帖子的类别链接。

如果您阅读了有关此函数的Wordpress codex,并查看您的代码以尝试并遵循它,这可能会更有用。

您还可以尝试更改参数以更改dropdown的输出。

https://codex.wordpress.org/Function_Reference/wp_dropdown_categories

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38892943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档