Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1429524

    Hi guys,

    Google has not been able to find me an answer.

    I’d like to add a widget area on the blog/news page just above the loop.

    Any idea what hook I need to do this?

    For the Woocommerce page it is as below but I need to same positioning on the blog page.

    // Add Widget above products on all shop pages
    add_action( 'woocommerce_before_shop_loop', 'enfold_customization_shop_widget_area', 50 );
    function enfold_customization_shop_widget_area() {
        dynamic_sidebar( 'shopheader' );
    }

    Any idea what I need?

    #1429528

    Hey Thomas,

    You can use the “ava_after_main_container” hook instead of the “woocommerce_before_shop_loop” for that.

    If you created your Blog page using ALB, the simpler way would be adding the Widget Area element to the top of your page and choosing your widget.

    Best regards,
    Yigit

    #1429530

    Hi Yigit,

    Thanks for this – This works but it is too high – It currently sits above the breadcrumbs.

    Is it possible to move it below?

    #1429539

    Hi,

    You could try using the ava_after_main_title or directly override the template files.

    Best regards,
    Ismael

    #1429547

    Thanks both…See private content link below.

    I have managed to do this using ava_after_main_container. It only needs to show on mobiles so I just used a media query to hide it.

    Once the sidebar hides it is actually in the right place so this worked out OK in the end.

    #1429549

    Hi!

    Great! Let us know if there is anything else we can help you with.

    Have a nice day.

    Best regards,
    Ismael

    #1465253

    Hi Guys,

    I need a hook that only loads above the blog.

    The hook suggested loads above all pages.

    can we get a hook for this. Sorry I have just raised a new ticket regarding this.

    The problem is the code above has now started showing on my woocommerce pages as well as the blog. This is new behaviour in version 6.03. So now my filter button on the shop doesnt work because it is also loading the button directly above it taking over the function.

    #1465307

    Hi,
    This seems to be a duplicate thread, please see your other thread:

    You could add a check for the page that you want you show it on, for example if the page ID is “1028” use this:

    add_action( 'ava_after_main_title', 'enfold_customization_blog_widget_area', 50 );
    function enfold_customization_blog_widget_area() {
        if ( is_page(1028) ) { 
            dynamic_sidebar( 'blogheaderwidget' );
        }
    }

    or you can use the page slug like this:

    add_action( 'ava_after_main_title', 'enfold_customization_blog_widget_area', 50 );
    function enfold_customization_blog_widget_area() {
        if ( is_page('your-page-slug') ) { 
            dynamic_sidebar( 'blogheaderwidget' );
        }
    }

    The WordPress Conditional Tags documentation state:

    There is no conditional tag for the blog page. You have to use both is_home() and is_front_page() to detect this page, but those functions can be misused.

    They offer a different solution, try reading it, but I think the two solutions above will work fine.

    Best regards,
    Mike

    #1465412

    Hi Mike,

    Sorry for the duplication – I forgot I had a thread on this already. I have posted this on both threads.

    Unfortunately what you have suggested doesnt work. BUT IT SHOULD!!!

    Using the documentation guide – This works:

    add_action( 'ava_after_main_title', 'enfold_customization_blog_widget_area', 50 );
    function enfold_customization_blog_widget_area() {
    	$check_tjnewswidget = true;
    	
    	if ( is_home() ) { 
        $check_tjnewswidget = false;
        }
    	
    	if( !$check_tjnewswidget ) {
            dynamic_sidebar( 'blogheaderwidget' );
        }
    }

    Not quite as per documentation but I like using the true and false method of determining if something is a particular thing.

    #1465422

    Hi,
    Glad to hear that you have this sorted out, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Hook to add widget area above blog loop?’ is closed to new replies.