Tagged: widget befor content
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;
}
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