Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
neilgee
/
set-sidebar-simple-sidebar-conditionally-genesis.php
Last active
Jan 28, 2018
Star
1
Fork
1
Star
Code
Revisions
7
Stars
1
Forks
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Set sidebar conditionally to target tags, categories and posts in Genesis.php
Raw
set-sidebar-simple-sidebar-conditionally-genesis.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
<?php
//do not copy the above opening php tag
add_action(
'genesis_before_sidebar_widget_area'
,
'themeprefix_remove_sidebar'
);
// starts the ball rolling
/**
* Conditionally Change Sidebar in Genesis whilst using Simple Sidebars
*
* @package Genesis Sidebar with Simple Sidebar Switcheroo
* @author Neil Gee
* @link https://wpbeaches.com/bulk-set-sidebar-categories-tags-simple-sidebars-installed-genesis/
* @copyright (c) 2014, Neil Gee
*/
function
themeprefix_remove_sidebar
() {
if
( is_single() || is_category() || is_tag() ) {
// set your connditionals here
remove_action(
'genesis_sidebar'
,
'ss_do_sidebar'
);
// removes Simple Sidebar
remove_action(
'genesis_sidebar'
,
'genesis_do_sidebar'
);
// removes Genesis Default sidebar
add_action(
'genesis_sidebar'
,
'themeprefix_add_sidebar'
);
// adds alternative sidebar in function below
}
}
// Alternative Sidebar
function
themeprefix_add_sidebar
() {
dynamic_sidebar(
'category-sidebar'
);
// add in the ID of the sidebar you want to replace it with
}
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.