How to delete Widget Areas in Wordpress

I am using WordPress to create a site for an estate agency. I would like to have a minimal homepage, with a text area and a background image. In the theme I am using (Agent Press) every page has 2 widget areas that I would like to delete. Is there a way to do it? I don't mind using any plugin or modifying code too. Thank you for your time and consideration.

Edit: this is my sidebar.php in the "father" theme called Genesis, where should I put the code you suggested me? (I don't know if it is right to edit this file)

<?php
/**
* Genesis Framework.
*
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this 
file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package Genesis\Templates
 * @author  StudioPress
 * @license GPL-2.0+
 * @link    http://my.studiopress.com/themes/genesis/
 */

//* Output primary sidebar structure
genesis_markup( array(
'html5'   => '<aside %s>' . genesis_sidebar_title( 'sidebar' ),
'xhtml'   => '<div id="sidebar" class="sidebar widget-area">',
'context' => 'sidebar-primary',
) );

do_action( 'genesis_before_sidebar_widget_area' );
do_action( 'genesis_sidebar' );
do_action( 'genesis_after_sidebar_widget_area' );

genesis_markup( array(
    'html5' => '</aside>', //* end .sidebar-primary
    'xhtml' => '</div>', //* end #sidebar
) );

Edit: Here you are the screenshot of the pages you want to know about, tell me which you want to know more about.

enter image description here

Edit: front-page.php

<?php
/**
* This file adds the Home Page to the AgentPress Pro Theme.
*
* @author StudioPress 
* @package AgentPress Pro
* @subpackage Customizations
*/

//* Enqueue scripts
add_action( 'wp_enqueue_scripts', 'agentpress_front_page_enqueue_scripts' 
 );
 function agentpress_front_page_enqueue_scripts() {

//* Load scripts only if custom background is being used
if ( ! get_option( 'agentpress-home-image' ) )
    return;

//* Enqueue Backstretch scripts
wp_enqueue_script( 'agentpress-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'agentpress-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agentpress-backstretch' ), '1.0.0' );

wp_localize_script( 'agentpress-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', get_option( 'agentpress-home-image' ) ) ) );

//* Add agentpress-pro-home body class
add_filter( 'body_class', 'agentpress_body_class' );

}

add_action( 'genesis_meta', 'agentpress_home_genesis_meta' );
/**
* Add widget support for homepage. If no widgets active, display the default loop.

* */ function agentpress_home_genesis_meta() {

if ( is_active_sidebar( 'home-featured' ) || is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-middle-1' ) || is_active_sidebar( 'home-middle-2' ) || is_active_sidebar( 'home-middle-3' ) || is_active_sidebar( 'home-bottom' ) ) {

    //* Force full-width-content layout setting
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

    //* Remove breadcrumbs
    remove_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_breadcrumbs' );

    //* Remove the default Genesis loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );

    //* Add home featured area
    add_action( 'genesis_after_header', 'agentpress_home_featured_widget' );

    //* Add home widget area
    add_action( 'genesis_before_footer', 'agentpress_home_widgets', 1 );

}

}

 function agentpress_body_class( $classes ) {

    $classes[] = 'agentpress-pro-home';
    return $classes;

}

function agentpress_home_featured_widget() {

genesis_widget_area( 'home-featured', array(
    'before' => '<div class="home-featured full-width widget-area"><div class="wrap">',
    'after' => '</div></div>',
) );

}

function agentpress_home_widgets() {

/*genesis_widget_area( 'home-top', array(
    'before' => '<div class="home-top full-width widget-area"><div class="wrap">',
    'after'  => '</div></div>',
) ); */



if ( is_active_sidebar( 'home-middle-1' ) || is_active_sidebar( 'home-middle-2' ) || is_active_sidebar( 'home-middle-3' ) ) {

    echo '<div class="home-middle"><div class="wrap">';

        genesis_widget_area( 'home-middle-1', array(
            'before' => '<div class="home-middle-1 full-width widget-area">',
            'after'  => '</div>',
        ) );

        genesis_widget_area( 'home-middle-2', array(
            'before' => '<div class="home-middle-2 widget-area">',
            'after'  => '</div>',
        ) );

        genesis_widget_area( 'home-middle-3', array(
            'before' => '<div class="home-middle-3 widget-area">',
            'after'  => '</div>',
        ) );

    echo '</div></div>';

}

genesis_widget_area( 'home-bottom', array(
    'before' => '<div class="home-bottom full-width widget-area"><div class="wrap">',
    'after'  => '</div></div>',
) );

}

genesis();`

Upvotes: 0

Views: 1973

Answers (2)

Mel
Mel

Reputation: 943

You need to set an if statement on your sidebar code. use the is_page() function of wordpress:

if( ! is_page('home') ){  // Remove the sidebar on home page

   dynamic_sidebar('your-sidebar-id');

}

You can also set your sidebar on a specific page via ID or slug.

if( is_page( 123 ) ){  // via ID

   dynamic_sidebar('your-sidebar-id-1');  // Sidebar 1

}elseif( is_page('contact-us') ){  // via slug

   dynamic_sidebar('your-sidebar-id-2');  // Sidebar 2

}

Upvotes: 1

Ali Ali
Ali Ali

Reputation: 1864

Edited:

  1. Navigate to Appearance > Editor on the left in the Wordpress Dashboard.
  2. On the Edit Themes page, select the sidbar.php page on the right hand side in the Templates section.
  3. The code for the sidebar.php will load in the Theme editor window.
  4. Add a comment to the code like in the snapshot to the right. HTML comments look like the following:
<!-- Begin Comment

Code goes in between here

End Comment -->

Add the comment code to the page in the Theme editor and Click Update File

Upvotes: 0

Related Questions