• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to user navigation

PopWP

WordPress and Genesis Tutorials

  • Get Started
  • About
  • Archive
  • Services
  • Membership
  • My Account

Register a Widget area and display it in Genesis

Last Updated on October 5, 2018 Favorited: 1 times

Adding custom contents to different places using Widgets in Genesis is simple and can be achieved using plugins or some line of codes.

Sidebar or Widget Area?

Since Genesis version 2.1.0, there is a new function genesis_register_widget_area that is identical to genesis_register_sidebar . There are few difference between them

Widget area can be registered anywhere using Genesis hooks while a sidebar is limited to display on their preferred layout setting. We Generally remove the primary sidebar while adding custom sidebar in Genesis site whereas custom widgets are registered without removing anything from default.

If you’re registering a widget area that’s not intended as a sidebar, you might find that the terminology of genesis_register_widget_area makes more sense.

However, there is no difference between them and usage is the same and You can use the genesis_register_sidebar to create front page widget sections or custom widget sections.

How to Create a Widget Area?

Step 1. Create and Register a Wiget Area. Add this in functions.php

//* Register a Simple Widget area
genesis_register_sidebar( array(
  'id'          => 'simple-widget',
  'name'        => __( 'Simple Widget', 'wpize' ),
  'description' => __( 'This is a simple widget area.', 'wpize' ),
) );

Step 2. Hook the Widget and Display it. Add this in functions.php

//* Add the Simple widget using Genesis Hook and Display it for me
add_action( 'genesis_before_content', 'wpize_simple_widget_content' );
function wpize_simple_widget_content() {
  genesis_widget_area ('simple-widget', array(
        'before' => '<div class="simple-widget widget-area"><div class="wrap">',
        'after' => '</div></div>',
  ) );
}

Additional:- Add some styles. Paste it in your CSS file.

.simple-widget {
    border: 1px solid rgba(240,245,250,.6);
    padding: 20px;
    margin: 10px;
    width: auto;
    background: #fafafa;
}

Want the Widget for the single post only? Yup, we can do it using Conditional tags.

Example:- Replace the Step 2. with this snippet.

//* Add this Simple widget using Genesis Hook and Conditional Tag
add_action( 'genesis_before_content', 'wpize_simple_widget_content' );
function wpize_simple_widget_content() {
if ( is_singular('post') ) {
  genesis_widget_area ('simple-widget', array(
        'before' => '<div class="simple-widget widget-area"><div class="wrap">',
        'after' => '</div></div>',
  ) );
  }
}

It’s done 🙂

Related Posts

  • Post list design showing featured image when hovered in Genesis
  • Custom Navigation Menu Location in Genesis Sample
  • Footer Widgets in Genesis
  • Custom Archive Page Template in Genesis
  • Utility Bar in Genesis Framework

Categories: Free Content, Genesis Tutorials Tags: custom, widgets

Reader Interactions

Primary Sidebar

Search

WPEngine WordPress Hosting, Perfected.

Hosting You are looking for?.
Perfect solution for small business to global enterprise.

Learn more

StudioPress Genesis Theme Framework

The No.1 Theme Provider.
Creative, SEO rich Theme for all niche projects.

Learn more

Categories

  • Free Content
  • Genesis Tutorials
  • Premium Content
  • Snippets
  • What's New?
  • WordPress Tutorials

Tag Cloud

Archive Background Section blog canvas menu center logo columns conditional tags CSS CSS Grid custom Customizer custom post type Custom Post Types custom template Custom Widget effect eNews Extended Featured Image front-page Genesis Genesis Sample header right hero section Image Background js layout left menu Logo menu Navigation Menu newsletter post page related posts responsive menu search search widget Shrinking Logo site header slide in-out Stylesheet Template Utility Bar Video Background widgets WordPress

Built with Genesis Framework + WordPress by Aryan Raj

  • Contact
  • FAQ
  • Disclaimer
  • Privacy Policy
  • Copyright Policy
  • Terms of Service