我爱水煮鱼 » WordPress » WordPress 技巧:如何从 WordPress 页面菜单中移除特定页面

WordPress 技巧:如何从 WordPress 页面菜单中移除特定页面

wp_list_pages() 中生成的页面菜单中移除特定的页面是非常简单的,只需要把下面代码加入到主题的 functions.php 文件中:

// add page ids to the exclude list
function my_banned_pages( $exclude_array ) {
    return array_merge( $exclude_array, array( 4, 17 ) );
}
add_filter( 'wp_list_pages_excludes', 'my_banned_pages' );

只需要把数组中的数字改成你要移除页面 ID 就可。

标签:

分享到:

请选择你看完该文章的感受:

不错 超赞 无聊 扯谈 不解 路过