INove主题导航同时显示页面也分类
现在用的主题是iNove,但是发现导航只能用页面,想用分类导航却不能。在网上找的方法,记录如下。
不过因为学校的个人主页这个主题里没有办法更改php文件,我在本地测试了一下,是可以成功的。
第一步:给主题设置里添加一个选项:show all(意思就是同时显示页面和分类)
1、在主题目录下找到functions.php文件,打开并在第220行找到:
<label>
<input name=”menu_type” type=”radio” value=”categories” <?php if($options['menu_type'] == ‘categories’) echo “checked=’checked’”; ?> />
<?php _e(‘Show categories as menu.’, ‘inove’); ?>
</label>
2、在下面添加:
<label>
<input name=”menu_type” type=”radio” value=”pages_and_categories” <?php if($options['menu_type'] == ‘pages_and_categories’) echo “checked=’checked’”; ?> />
<?php _e(‘Show All.’, ‘inove’); ?>
</label>
第二步:实现showall功能:
1、在主题目录下inove/templates找到header.php打开在第30行找到
<?php if($options['menu_type'] == ‘categories’) {wp_list_categories(‘title_li=0&orderby=name&show_count=0′);}
else {wp_list_pages(‘title_li=0&sort_column=menu_order’);}
?>
2、将上面的代码替换为:
<?php
if($options['menu_type'] == ‘categories’ || $options['menu_type'] == ‘pages_and_categories’) {wp_list_categories(‘title_li=0&orderby=name&show_count=0′);}
if($options['menu_type'] == ‘pages’ || $options['menu_type'] == ‘pages_and_categories’) {wp_list_pages(‘title_li=0&sort_column=menu_order’);}
?>
上面的意思是先显示分类再显示页面,如果你喜欢把页面放在分类前面那就把上面的代码换成:
<?php
if($options['menu_type'] == ‘pages’ || $options['menu_type'] == ‘pages_and_categories’) {wp_list_pages(‘title_li=0&sort_column=menu_order’);}
if($options['menu_type'] == ‘categories’ || $options['menu_type'] == ‘pages_and_categories’) {wp_list_categories(‘title_li=0&orderby=name&show_count=0′);}
?>
第三步:让页面与分类在导航同时出现:
打开网站管理后台:找到外观>>当前主题选项>>菜单栏>>选择Show All. ,然后保存就好了。