Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #795972

    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…

    #796115

    Hey teme,

    May you provide us your website link and the WP credentials?

    Best regards,
    John Torvik

    #796152

    Attached.

    #796438

    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?

    #796509

    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

    #796526

    Yes this works, thanks!

    #796532

    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

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Adding widget areas before & after single post content’ is closed to new replies.