Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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 如何使wp_下拉页面返回slug而不是id?_Wordpress - Fatal编程技术网

Wordpress 如何使wp_下拉页面返回slug而不是id?

Wordpress 如何使wp_下拉页面返回slug而不是id?,wordpress,Wordpress,我花了很多时间使用Wordpress wp_下拉列表_页面实现页面重定向 我怎么能有页面slug而不是页面id的选项 PHP部分: $string .= '<form id="child_page" action="'. home_url() . '">'; $childpages = wp_dropdown_pages( $args ); $string .= $childpages; $string .= '</form>'; return $string; })

我花了很多时间使用Wordpress wp_下拉列表_页面实现页面重定向

我怎么能有页面slug而不是页面id的选项

PHP部分:

$string .= '<form id="child_page" action="'. home_url() . '">';
$childpages = wp_dropdown_pages( $args );
$string .= $childpages;
$string .= '</form>';
return $string;
})


除了选项值是PageID而不是PageSlug之外,一切都按预期工作。

好吧,为什么经过几个小时的谷歌搜索和拔毛后,只有当我在这里发布内容时,我自己才能找到答案:

使用“值_字段”和有效的post字段,即post_名称。。。唉


谢谢。

你的目标是什么?请说明你想要实现什么,到目前为止你已经尝试了什么,以及你遇到了什么困难。我只是尝试使用wp\u下拉页面重定向页面。但是使用页面id会破坏站点,所以我必须使用页面slug。但我根本不知道如何让它返回选项值的slug,而不是pageid。有意义吗?我在插件中这样做:$string.=;$childpages=wp\u下拉菜单\u页面$args;$string.=$childpages;$string.=;在javascript中使用:$document.readyfunction{$'selectchild_page'。在'change'上,函数e{window.location.href=$'formchild_page'。attr'action'+'/'+$this.val;};
$(document).ready(function () {
$('select#child_page').on('change', function ( e ) {
    window.location.href = $('form#child_page').attr('action') + '/' + $(this).val();
});