A post can have multiple categories and/or tags. To make the feature you are asking for work it would need to have a system for you to assign a unique priority per category & tag (and terms in custom taxonomies if your install had custom taxonomies). It’s not practical to implement.
I see your point. The code in my functions.php worked well enough. I guess I just need to figure out why it’s breaking the menu format.
Thank you for your plugin.
@gretchen Louise Hi, I am looking for the same functionality. did you manage to make it work??
(I know Ron said, a post can have multiple categories..
but in my case, I use always 1 category per post..
so if the code above was reworked for genesis… it would be really helpful!
kris
I don’t remember now who helped me fix it, but this is the code I’m using (and it works!). Hope it’s helpful for you, Kriskl.
// Sidebar dependent on category
add_action('get_header', 'child_sidebar_logic');
function child_sidebar_logic() {
if ( function_exists('ss_do_sidebar') ) {
remove_action('genesis_sidebar', 'ss_do_sidebar');
} else {
remove_action('genesis_sidebar', 'genesis_do_sidebar');
}
add_action('genesis_sidebar', 'child_do_sidebar');
}
function child_do_sidebar() {
if ( in_category( 'tech' ) && !is_front_page() && !is_home() ) { if ( dynamic_sidebar( 'tech' ) ) return;
}
if ( function_exists('ss_do_sidebar') ) ss_do_sidebar();
else genesis_do_sidebar();
}
// Subnav dependent on category
remove_action('genesis_after_header', 'genesis_do_subnav');
add_action('genesis_after_header', 'custom_do_subnav');
function custom_do_subnav() {
echo '<div id="subnav"><div class="wrap"><ul id="menu-tech-2" class="menu genesis-nav-menu menu-secondary superfish sf-js-enabled">';
if ( is_single && in_category('tech')) { wp_nav_menu( array('menu' => 'Tech' ));
}
else {
genesis_do_subnav();
}
echo '</ul></div></div>';
}
Oh, thank you for much Louise!
it almost works perfectly. will have to to some tweaking (for some reason, it loads conditional menu on the front page..
but anyway, thank you! it is what I was looking for
Ron, there is a plugin to make single post for 1 category only called: Only One Category
So maybe the idea to make the Genesis simple menus plugin – into Genesis Magic Menus not such a stupid idea 🙂
provided that the “Only 1 Category” plugin is required for Genesis Magic Menus to work..