Forum Replies Created
-
AuthorPosts
-
August 26, 2013 at 4:26 pm in reply to: Metro Theme How to Replace Primary Sidebar for home.php Only #58937Andrew HandMember
Just to summarize what works here. Jen's post located here:
http://dreamwhisperdesigns.com/genesis-tutorials/load-sidebar-specific-pages/
Altering this code to be this (removing the conditional statement from the original):
add_action( 'get_header', 'child_sidebar_logic' ); /** * Swap in a different sidebar instead of the default sidebar. * * @author Jennifer Baumann * @link http://dreamwhisperdesigns.com/?p=1034 */ function child_sidebar_logic() { remove_action( 'genesis_after_content', 'genesis_get_sidebar' ); add_action( 'genesis_after_content', 'child_get_blog_sidebar' ); } /** * Retrieve blog sidebar */ function child_get_blog_sidebar() { get_sidebar( 'content' ); }
This works to replace the Primary Sidebar with this custom one I created as seen in sidebar-content.php that Jen's tutorial walks you thru and put in home.php rather than functions.php
This method works and will solve the issue of allowing home.php to have a unique sidebar only used there. The issue is wondering what the "much easier" way of doing this that she mentions is.
Hope this helps anyone else trying to accomplish the same thing and I have to thank Nick from StudioPress support for telling me that moving this to home.php would accomplish the goal.
August 26, 2013 at 4:17 pm in reply to: Metro Theme How to Replace Primary Sidebar for home.php Only #58936Andrew HandMemberIt seems like adding in even more code to be output isn't the best answer. I just altered Jen's code to strip the conditional statement and added it to home.php and removing it from the functions.php file.
This works in rendering that custom sidebar I created only on the Home Page. All I had to do was swap the widgets between my Primary Sidebar and custom one.
The issue I wonder about is Jen's own statement that her code is outdated and there's an even easier way to accomplish this other than having a sidebar-content.php file, registering the sidebar in functions.php and now calling it in home.php.
I'm wondering WHAT that easier and "better" way is.
Thanks for the ideas!
August 26, 2013 at 4:03 pm in reply to: Metro Theme How to Replace Primary Sidebar for home.php Only #58932Andrew HandMemberHey, so I already have Simple Sidebars installed. The problem is that the Metro theme will display the Primary sidebar on 404 pages, archive pages, etc, so while Jen's code fixes this, and it's worked fine, it breaks with a bbpress installation, which I just added and hence reached this new challenge.
The ideal solution is to simply alter the home.php code. The Home page needs to have a sidebar NOT used by any other pages, i.e. archives, 404, bbpress pages, etc.
The point of this is for the Home Page to be a squeeze page and have a unique opt-in form only used there. The "in-site" content is meant to have a full sidebar with several other widgets in it.
Hope that makes sense.
August 26, 2013 at 3:52 pm in reply to: Metro Theme How to Replace Primary Sidebar for home.php Only #58929Andrew HandMemberHey, so I currently used Jennifer Baumann's code for adding a custom sidebar to all post and page types to eliminate the Primary Sidebar from displaying, hence it only ends up being used on home.php
It's super Frankenstein and backwards but it's reverse elimination since I couldn't find any other way to do it the more logical way...
That being alter home.php to use a custom sidebar rather than the primary sidebar and then put the widgets used in my replacement sidebars and drop them back into the primary sidebar.
Whew...hope that made sense 🙂
Here's Jen's code:
add_action( 'get_header', 'child_sidebar_logic' ); /** * Swap in a different sidebar instead of the default sidebar. * * @author Jennifer Baumann * @link http://dreamwhisperdesigns.com/?p=1034 */ function child_sidebar_logic() { if ( is_page_template( 'page_blog.php' ) || is_archive() || is_404() || is_single() ), get_post_type() ) { remove_action( 'genesis_after_content', 'genesis_get_sidebar' ); add_action( 'genesis_after_content', 'child_get_blog_sidebar' ); } } /** * Retrieve blog sidebar */ function child_get_blog_sidebar() { get_sidebar( 'content' ); }
-
AuthorPosts