Hi there
I’m trying to insert the excerpt after the page title and rather than build each page with the layout builder i’m looking at a function. I’ve got this so far but don’t want to try in case it breaks the site. Any thoughts would be great.
add_action('ava_after_main_title', function() {
if ( is_page() || is_single() || is_singular( 'portfolio' ) ) {
echo '<div class="container">';
add_filter( 'excerpt_more' );
echo '</div>';
}
});
Richard
Hey raslade,
Please try this code instead (you can add it to the functions.php):
add_filter('avf_title_args', 'avf_title_args_mod_excerpt', 99, 2);
function avf_title_args_mod_excerpt($args,$id)
{
$excerpt = get_the_excerpt($id);
if(!empty($excerpt))
{
if(!empty($args['subtitle']))
{
$args['subtitle'] .= ' ' . $excerpt;
}else{
$args['subtitle'] = $excerpt;
}
}
return $args;
}
Best regards,
Peter
Thanks Peter, i’ve tried adding but there are some syntax errors. Could you try your end. Also will this add the excerpt below the page title as ava_after_main_title
is not included?
Richard
Hi,
Can you please make sure you copy it from the forums and not any emails?
Best regards,
Basilis
OK thanks. I’ve tried the code and getting:
FATAL ERROR syntax error, unexpected '{' on line number 8
Hey!
I forgot a bracket – I updated the code above – please try it again.
Regards,
Peter
Perfect, thank you for fixing.
Richard