Tagged: above loop, Blog, enfold, extra widget, Widget
-
AuthorPosts
-
January 8, 2024 at 10:05 am #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?
January 8, 2024 at 10:33 am #1429528Hey 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,
YigitJanuary 8, 2024 at 11:17 am #1429530Hi Yigit,
Thanks for this – This works but it is too high – It currently sits above the breadcrumbs.
Is it possible to move it below?
January 8, 2024 at 11:52 am #1429539Hi,
You could try using the ava_after_main_title or directly override the template files.
Best regards,
IsmaelJanuary 8, 2024 at 12:24 pm #1429547Thanks 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.
January 8, 2024 at 12:29 pm #1429549Hi!
Great! Let us know if there is anything else we can help you with.
Have a nice day.
Best regards,
IsmaelAugust 23, 2024 at 5:16 pm #1465253Hi 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.
August 24, 2024 at 6:59 pm #1465307Hi,
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,
MikeAugust 26, 2024 at 1:03 pm #1465412Hi 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.
August 26, 2024 at 4:43 pm #1465422Hi,
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 -
AuthorPosts
- The topic ‘Hook to add widget area above blog loop?’ is closed to new replies.