removing widgets from Home page

Community Forums Forums Design Tips and Tricks removing widgets from Home page

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  braddalton 8 months, 4 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #91627

    fotodog13
    Participant
    Post count: 50

    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/
    #91890

    braddalton
    Participant
    Post count: 10553

    Add [php]!is_home()[/php] after the function to exclude the posts page according to your Reading Settings

    Or [php]!is_front_page()[/php]

    Example:
    [php]
    if (is_active_sidebar( ‘middle-widget-b3′ ) && !is_front_page() ) {
    [/php]

    Note: Please use Github Gists to embed PHP code in a webpage. Thanks


    #92027

    fotodog13
    Participant
    Post count: 50

    Hey 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 similar

    Hope 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

    #92064

    braddalton
    Participant
    Post count: 10553

    I 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.


    #92107

    fotodog13
    Participant
    Post count: 50

    Hmmm- 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 V

    #92219

    braddalton
    Participant
    Post count: 10553
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.