Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1427159

    Hello,

    I want to add a widget above the content on a single post – single.php before the content. It needs to be full width.

    I found how to do it after the content. But not before the content.

    add_filter(‘avf_template_builder_content’, ‘avf_template_builder_content_comment_mod’ , 1 , 10);
    function avf_template_builder_content_comment_mod($content = “”)
    {
    if(is_singular(‘post’) || is_singular(‘portfolio’)){
    $sidebar_content = do_shortcode(“[av_sidebar widget_area='before-post-content']“);
    $content = $content . $sidebar_content ;
    }
    return $content;
    }

    #1427192

    Hey Josh,

    Thank you for the inquiry.

    You can simply reverse the order of $sidebar_content and $content to place the widget area before the content. Please replace the code in the function.php file.

    function avf_template_builder_content_mod($content = "")
    {
        if (is_singular('post') || is_singular('portfolio')) {
            $sidebar_content = do_shortcode("[av_sidebar widget_area='before-post-content']");
            $content = $sidebar_content . $content;
        }
        return $content;
    }
    add_filter('avf_template_builder_content', 'avf_template_builder_content_mod', 10, 1);
    

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.