Site logo

Archived topic

code sinppet is valid only for the right sidebar

3 replies · Started by Yassine on April 4, 2022

Viewing posts 1–4 of 4

Hi,

This code sinppet bellow is valid only for the right sidebar, How to apply it for the left sidebar

add_action('generate_before_comments', 'inser_sidebar_before_comment');
function inser_sidebar_before_comment() {
if ( is_single() && wp_is_mobile() ) {
return get_sidebar();
}
}

Hi Yassine,

Can you try this for the left sidebar instead?:

add_action('generate_before_comments', 'inser_sidebar_before_comment');
function inser_sidebar_before_comment() {
if ( is_single() && wp_is_mobile() ) {
return get_sidebar( 'left' );
}
}

If you wish both to appear there, you can try:

add_action('generate_before_comments', 'inser_sidebar_before_comment');
function inser_sidebar_before_comment() {
if ( is_single() && wp_is_mobile() ) {
return get_sidebar( 'left' ) + get_sidebar();
}
}

Kindly let us know how it goes. :)

Thanks, Its worked : )

You’re welcome Yassine! Glad that worked! Feel free to reach out anytime you’ll need assistance with anything else. :)

This archived topic is closed to new replies.