Community Forums › Forums › Archived Forums › Design Tips and Tricks › removing widgets from Home page
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by Brad Dalton.
-
AuthorPosts
-
February 21, 2014 at 8:41 am #91627fotodog13Participant
Looking for a little bit of help trying to remove a set of widgets from appearing on my home page, but stay visible on all of the other pages.
I am using the Metric theme ( current version )
Below is the code I placed in my functions.php to add the widgets. This works perfectly except I cannot seem to get it to style on the home page- so my thought is just to remove them from appearing on the home page.
I am thinking that a new hook, or conditional statement could be added to prevent these widgets from appearing on the home page.
Have been messing around with this for a couple of days now so would really appreciate if someone could point me in the right direction on how to do this.
genesis_register_sidebar( array(
'id' => 'middle-widget-b1',
'name' => __( 'Middle-Widget-B1', 'metric' ),
'description' => __( 'This is the set of widgets directly above the footer widgets', 'metric' ),
) );
/**
* @author Brad Dalton - WP Sites
* @example http://wpsites.net/web-design/feature-box-genesis-home-page/
*/
add_action( 'genesis_after_content', 'genesis_middle_widget_b1' );
function genesis_middle_widget_b1() {
if (is_active_sidebar('middle-widget-b1' ) ) {
genesis_widget_area( 'middle-widget-b1', array(
'before' => '<div class="middle-widget-b1" class="widget-area">',
'after' => '</div>',
) );}}
genesis_register_sidebar( array(
'id' => 'middle-widget-b2',
'name' => __( 'Middle-Widget-B2', 'metric' ),
'description' => __( 'This is the middle set of widgets directly above the footer widgets ib row b', 'metric' ),
) );
/**
* @author Brad Dalton - WP Sites
* @example http://wpsites.net/web-design/feature-box-genesis-home-page/
*/
add_action( 'genesis_after_content', 'genesis_middle_widget_b2' );
function genesis_middle_widget_b2() {
if (is_active_sidebar( 'middle-widget-b2' ) ) {
genesis_widget_area( 'middle-widget-b2', array(
'before' => '<div class="middle-widget-b2" class="widget-area">',
'after' => '</div>',
) );}}
genesis_register_sidebar( array(
'id' => 'middle-widget-b3',
'name' => __( 'Middle-Widget-B3', 'metric' ),
'description' => __( 'This is the middle set of widgets directly above the footer widgets ib row b far right', 'metric' ),
) );
/**
* @author Brad Dalton - WP Sites
* @example http://wpsites.net/web-design/feature-box-genesis-home-page/
*/
add_action( 'genesis_after_content', 'genesis_middle_widget_b3' );
function genesis_middle_widget_b3() {
if (is_active_sidebar( 'middle-widget-b3' ) ) {
genesis_widget_area( 'middle-widget-b3', array(
'before' => '<div class="middle-widget-b3" class="widget-area">',
'after' => '</div>',
) );}}
Best Scott V
http://69.195.124.163/~aielloho/February 22, 2014 at 3:06 am #91890Brad DaltonParticipantAdd
!is_home()
after the function to exclude the posts page according to your Reading Settings
Or
!is_front_page()
Example:
if (is_active_sidebar( 'middle-widget-b3' ) && !is_front_page() ) {
Note: Please use Github Gists to embed PHP code in a webpage. Thanks
February 23, 2014 at 11:14 am #92027fotodog13ParticipantHey Brad- thanks so much for your reply - this seemed to solve the problem for me with the home page.
I do have another question- thats somewhat related to this same issue- hoping that I can get a bit more input on this from you.I installed the following plugin
http://strategy11.com/display-widgets/so that I could toggle these b1,b2,b3 widgets on/off on certain pages without having to recreate a bunch of unique sidebars, and code ( coding as you can tell is not my strongest suit- but you have to start some where- slowly but surely )
I have started to notice that the alignment for the widgets middle-widget-b1, middle-widget-b2,middle-widget-b3 can vary depending on the length and type of the page being displayed.
If you look at the bottom of these 2 pages ( make a difference box, and the sign up email box ) and look at the space between the 2 boxes you will see what I mean.
http://69.195.124.163/~aielloho/plumbing-service-repair/
and
http://69.195.124.163/~aielloho/home-air-conditioning-repair-service-and-installation/I am wondering if there is a way to "easily" correct this through the functions.php file
When I look at that file I see the hook is being called as
add_action( ‘genesis_after_content’, ‘genesis_middle_widget_b2′ );I have tried changing this to " before_ footer" with no luck.
My thinking was if the middle_widget_b1,b2,b3 were either part of the " content inner"
or if they were " wrapped"
within a div id- I might be able to have better control over the styling of them so that all of the pages appear similarHope the above makes sense- and I did not just confuse the heck out of you. Would love any insight you might have on this
thanks
Scott V
PS- big fan of your site "http://wpsites.net/bradley-james-dalton-wordpress-developer/" - its a big help
February 23, 2014 at 7:56 pm #92064Brad DaltonParticipantI would consider updating to HTML 5 as its cleaner markup which validates better.
You may need to change any loop hooks in your functions file if you do this.
Not sure what classes you're using for your widgets but widgets native to the theme should always work well so you might want to use the same classes for custom widgets.
February 24, 2014 at 5:58 am #92107fotodog13ParticipantHmmm- had a feeling you might say that- was hoping that there was another solution but have a feeling that in the long run thats probably the best one
thanks again
Best
Scott VFebruary 24, 2014 at 5:46 pm #92219 -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.