Community Forums › Forums › Archived Forums › General Discussion › Swap out primary-nav?
- This topic has 10 replies, 3 voices, and was last updated 10 years, 6 months ago by aranya.
-
AuthorPosts
-
October 9, 2013 at 6:09 pm #66036aranyaMember
I'm trying to swap the primary-nav for the secondary-nav on some pages and move the secondary-nav to where I have the primary-nav located. Currently, all that is happening is that the secondary-nav is being removed. Can anyone spot the problem in the following code:
/**
* Swap in a different main navigation menu for English pages.
*/
if ( in_category( '59' ) ) {
add_theme_support( 'genesis-menus', array( 'secondary' => __( 'Secondary Navigation Menu', 'genesis' ) ) );
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_header', 'genesis_do_subnav' );
} else {
add_theme_support( 'genesis-menus', array( 'primary' => __( 'Primary Navigation Menu', 'genesis' ) ) );
}October 9, 2013 at 10:53 pm #66068Sridhar KatakamParticipantOctober 10, 2013 at 7:33 am #66120aranyaMemberIt's one that I made myself.
October 10, 2013 at 7:47 am #66124aranyaMemberSomehow the conditional isn't working. I always get the "else" option.
October 10, 2013 at 6:02 pm #66190SummerMemberWhy not just create a category-59.php template and do what you need there instead? That way you won't have to mess with conditionals at all.
Also, it makes more sense to have both "add_theme_support" functions outside the conditionals, because you do want them both enabled... all you said you wanted was to swap them based on which pages are active.
So this would be in functions.php:
add_theme_support( 'genesis-menus', array( 'primary' => __( 'Primary Navigation Menu', 'genesis' ) ) ); add_theme_support( 'genesis-menus', array( 'secondary' => __( 'Secondary Navigation Menu', 'genesis' ) ) );
and this would be ony in category-59.php:
remove_action( 'genesis_after_header', 'genesis_do_subnav' ) ; add_action( 'genesis_before_header', 'genesis_do_subnav' );
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkOctober 10, 2013 at 8:49 pm #66214aranyaMemberThanks, that's a great idea. I should already know this, but is there an easy way to go about making a template for posts rather than pages?
October 11, 2013 at 12:25 pm #66316SummerMemberThey are pretty much the same, save for the naming conventions.
WordPress template naming conventions here: http://codex.wordpress.org/Template_Hierarchy
When you name your templates following that structure, and put them in your child theme folder, poof, you customize layouts for any of your categories, custom post types, etc.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkOctober 11, 2013 at 12:43 pm #66319aranyaMemberIt looked to me like you can make a custom template for a category page, but for a post in a particular category, the post has to have a custom post type in order to apply a certain template. Did I read that right?
I should have done a custom post type for my English pages, but unfortunately I didn't.
October 11, 2013 at 1:02 pm #66320aranyaMemberMaybe I should just use one of those custom templates for posts plugins?
October 11, 2013 at 3:06 pm #66341SummerMemberYou can use single.php for regular posts, and then use conditionals in there to select based on category, if you wanted to differentiate them even more.
If those plugins play nicely with Genesis, that might work if you wanted to have different layouts for single posts in different categories. I've never played with any of them, so I couldn't supply any recommendations or pointers there.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkOctober 13, 2013 at 7:04 pm #66561aranyaMemberPerfect. Thank you!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.