I’m trying to add widget areas before & after single post content. Here’s my code from child theme’s functions.php:
add_action(‘ava_after_main_container’, ‘custom_func_1’, 10, 2);
function custom_func_1($id, $context) {
if($context == ‘post’){
echo do_shortcode(“[av_sidebar widget_area='article-top']“);
}
}
add_action(‘ava_after_content’, ‘custom_func_2’, 10, 2);
function custom_func_2($id, $context) {
if($context == ‘post’){
echo do_shortcode(“[av_sidebar widget_area='article-bottom']“);
}
}
… the second part works (ava_after_content), but the first part doesn’t add that widget area anywhere on the page. I don’t know php at all, so there’s probably some stupid mistake here…
Hey teme,
May you provide us your website link and the WP credentials?
Best regards,
John Torvik
Attached.
I found out that the “if($context == ‘post’)” is the problem, it doesn’t work with ava_after_main_container but it works with ava_after_content. Is there any other hook which I could try, which would insert the code only to single post page before content?
Hi,
Please try using the code as following
add_action('ava_after_main_container', 'custom_func_1', 10, 2);
function custom_func_1() {
if(is_single()){
dynamic_sidebar( 'article-top' );
}
}
Best regards,
Yigit
Yes this works, thanks!
Hi,
You are welcome! :)
For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/
And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/
For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you :)
Best regards,
Yigit