Custom navigation
Since version 1.2 of the Visionary theme, there are no navigation files to edit by default.
Important: If you’re on an older version than 1.2.1, then you need to upgrade because there are some bugs.
To change your navigation, you need only add a function or two to your child theme’s functions.php file. If you’re unsure about what I’m talking about when it comes to child themes, you need to step over to the support forums and take a look at a few of the sticky posts. There’s also documentation on modifying the theme the right way.
- Custom page navigation
- Custom category navigation
- Remove the page navigation
- Remove the category navigation
Custom page navigation
First, you should read how the wp_list_pages() function works from the WordPress Codex. Otherwise, all of the below will be trivial.
We need to write a simple function to change the default. Here’s an example with a “Home” link added (remember that this goes in your child theme’s functions.php file):
<?php
function my_custom_nav() {
?>
<ul id="nav">
<li class="page_item<?php if(is_home()) { echo ' current_page_item'; } ?>"><a href="<?php bloginfo('url'); ?>" title="Home">Home</a></li>
<?php wp_list_pages('title_li=&depth=3&sort_column=menu_order'); ?>
</ul>
<?php
}
Then, we need to filter the original function:
add_filter( 'visionary_page_nav', 'my_custom_nav' ); ?>
That’s all you need to do. Pretty simple, right?
Custom category navigation
You might want to change your category links up a bit. Well, we’d do the same thing as we did with the page navigation.
wp_list_categories is your friend. Read about it. Learn how it works.
Add this function to your child theme’s functions.php file:
<?php
function my_custom_cat_nav() { ?>
<ul id="sub-nav">
<?php wp_list_categories('title_li=&use_desc_for_title=0&orderby=name'); ?>
</ul>
<?php }
Then, we need to filter the original code by adding this line:
add_filter( 'visionary_cat_nav', 'my_custom_cat_nav' );
?>
That’s it. Just customize to your liking.
How to remove the page navigation
Maybe you want a pure news site look and need to get rid of the page navigation. That’s easy. In your child theme’s functions.php file, add this:
<?php
add_action('wp_head','remove_page_nav');
function remove_page_nav() {
remove_action('visionary_after_header','visionary_page_nav');
}
?>
This function tells your theme to remove the page navigation from the theme hook it’s attached to.
How to remove the category navigation
If you want to completely remove the category navigation from your blog, just add this in your child theme’s functions.php file.
<?php
add_action('wp_head','remove_cat_nav');
function remove_cat_nav() {
remove_action('visionary_before_header','visionary_cat_nav');
}
?>
Basically, you’re just removing an action from one of the theme hooks.