NunYa
NunYa

Reputation: 21

wordpress widget in shop pages array doesn't work on main store page

The widget area displays fine in all pages designated EXCEPT the main store page, 7432.

// Store Banner genesis_register_sidebar( array( 'id' => 'store-banner', 'name' => __( 'Store Banner', 'genesis' ), 'description' => __( 'Add Content Here', 'genesis' ), ) );

add_action( 'genesis_before_content_sidebar_wrap', 'genesis_before_content_sidebar_wrap'                   );
function genesis_before_content_sidebar_wrap() {
if ( is_page ( array( '7432', '7433', '7434', '7435', '7436') ) ) {
genesis_widget_area( 'store-banner', array(
    'before' => '<div class="store-banner" class="widget-area">',
    'after'  => '</div>',
) );
}
}

I have subbed out the page slug for the number: if ( is_page ( array( 'shop', '7433', '7434', '7435', '7436') ) ) { No joy.

The only way I've gotten the display on the shop page is with the following: if ( is_shop() && is_active_sidebar('store-banner') ) {

Though I note that including the active sidebar check in the array code example crashes the site: if ( is_page ( array( '7432', '7433', '7434', '7435', '7436') ) ) && is_active_sidebar('store-banner') ) {

I suppose I can do without the active sidebar check in this case but surely there's a way to make it all correct?

I'm obviously not a coder, just an old hack cobbling things together using pieces from smart people, so I thank you in advance for your assistance.

https://richardgage911.org/store/

Upvotes: 0

Views: 36

Answers (1)

NunYa
NunYa

Reputation: 21

genesis_register_sidebar( array(
'id'          => 'store-banner',
'name'        => __( 'Store Banner', 'genesis' ),
'description' => __( 'Add Content Here', 'genesis' ),
) );

add_action( 'genesis_before_content_sidebar_wrap', 
'genesis_before_content_sidebar_wrap' );
function genesis_before_content_sidebar_wrap() {
if ( is_page ( array( '7433', '7434', '7435', '7436') ) || is_shop()) {
genesis_widget_area( 'store-banner', array(
    'before' => '<div class="store-banner" class="widget-area">',
    'after'  => '</div>',
) );
}
}

This code works to get it into the store page as well as the others in the array, but still no joy trying to add the active sidebar check. Still looking for that portion.

Upvotes: 0

Related Questions