WordPress 和使用 wp_page_menu 的自定义菜单
我使用以下代码将自定义分类法添加到 WordPress 的菜单中。我需要在产品下制作这些“子”项目。
现在他们出现的例子:
Photography > Lighting
Photography > Cameras
我需要他们出现
Products > Photography > Lighting
Products > Photography > Cameras
add_filter( 'wp_page_menu', 'custom_page_nav', 90 );
function custom_page_nav( $menu )
{
$taxonomy = 'catalog';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 1; // 1 for yes, 0 for no
$hierarchical = true; // 1 for yes, 0 for no
$title = '';
$args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical, 'title_li' => false, 'echo' => false, 'empty' => true, 'hide_empty' => false,
'depth' => 0 );
$links .= wp_list_categories( $args );
// $links .= wp_list_categories( array( 'title_li' => false, 'echo' => false, 'empty' => true ) );
$menu = str_replace( '', $links . '', $menu );
return $menu;
}
I'm using the following code to add custom taxonomies to my menu in wordpress. I need to make these "sub" items under Products.
Example right now they are showing up:
Photography > Lighting
Photography > Cameras
I need them to show up as
Products > Photography > Lighting
Products > Photography > Cameras
add_filter( 'wp_page_menu', 'custom_page_nav', 90 );
function custom_page_nav( $menu )
{
$taxonomy = 'catalog';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 1; // 1 for yes, 0 for no
$hierarchical = true; // 1 for yes, 0 for no
$title = '';
$args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical, 'title_li' => false, 'echo' => false, 'empty' => true, 'hide_empty' => false,
'depth' => 0 );
$links .= wp_list_categories( $args );
// $links .= wp_list_categories( array( 'title_li' => false, 'echo' => false, 'empty' => true ) );
$menu = str_replace( '', $links . '', $menu );
return $menu;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)