Php wordpress菜单导航存档下拉链接
我正在尝试为我的wordpress站点添加一个下拉存档菜单。 我一直在努力遵循wordpress的抄本,我可以让它工作,但我不知道如何让它进入我的菜单,我在wordpress 我已经为它做了一个函数,但我不能完全确定我是否理解如何正确地编写“and”Php wordpress菜单导航存档下拉链接,php,wordpress,Php,Wordpress,我正在尝试为我的wordpress站点添加一个下拉存档菜单。 我一直在努力遵循wordpress的抄本,我可以让它工作,但我不知道如何让它进入我的菜单,我在wordpress 我已经为它做了一个函数,但我不能完全确定我是否理解如何正确地编写“and” function wp\u menu\u archive($args){ $args= 回显esc_attr(_uuu('Select Month')); wp_get_归档文件(数组('type'=>'monthly','format'=>'选项
function wp\u menu\u archive($args){
$args=
回显esc_attr(_uuu('Select Month'));
wp_get_归档文件(数组('type'=>'monthly','format'=>'选项','show_post_count'=>1));
';
返回$items.=$args ;
}
添加过滤器(“wp\U导航菜单项”,“wp\U菜单存档”,52,2);
为什么使用$args
然后返回空的$items
用$items
更改$args
function wp_menu_archive( $items ) {
$archives = '<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""> ' . esc_attr( __( 'Select Month' ) ) . ' </option> ' ;
$archives .= wp_get_archives( array( 'type' => 'monthly',
'format' => 'option',
'echo' => 0,
'show_post_count' => 1 )
);
$archives .= '</select>';
return $items .= $archives ;
}
add_filter( 'wp_nav_menu_items', 'wp_menu_archive', 52, 2 );
function wp\u menu\u archive($items){
$1
“.esc_attr('Select Month')”;
$archives.=wp\u get\u存档(数组('type'=>'monthly',
'格式'=>'选项',
“echo”=>0,
'show_post_count'=>1)
);
$archives.='';
返回$items.=$archives;
}
添加过滤器(“wp\U导航菜单项”,“wp\U菜单存档”,52,2);
我现在记不清wp\u get\u archives
的确切输出,但这应该是可行的
(此外,您所有的连接语法都是错误的…)
编辑
好的,很抱歉,现在检查代码,您需要在
wp_get_archives()
中再添加一个参数,即'echo'=>0,
。我更新了代码。(我们需要返回,而不是直接echo
)非常感谢您的帮助,但这似乎是该代码中的语法错误。我认为它出现在最后3行中。(首先,我认为“show\u post\u count”=>1应该是“show\u post\u count”=>“1”,但这没有帮助。很抱歉,我现在没有访问服务器或源代码的权限。但是删除函数最后两行的
和=
之间的空格:-)很有魅力!非常感谢!对..我想知道你什么时候能完成你的大菜单。我希望至少你能给我们看看..-)哈哈,当然我会展示,但这需要一些时间。我还有一些问题,但我觉得发垃圾邮件很糟糕,所以我尝试了几天来解决它并学习。如果这里有PM功能,我会给你一个潜行峰值。
function wp_menu_archive( $items ) {
$archives = '<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""> ' . esc_attr( __( 'Select Month' ) ) . ' </option> ' ;
$archives .= wp_get_archives( array( 'type' => 'monthly',
'format' => 'option',
'echo' => 0,
'show_post_count' => 1 )
);
$archives .= '</select>';
return $items .= $archives ;
}
add_filter( 'wp_nav_menu_items', 'wp_menu_archive', 52, 2 );