-
AuthorPosts
-
September 6, 2018 at 5:37 pm #1006755
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
September 7, 2018 at 10:02 am #1007008Hey 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,
PeterSeptember 7, 2018 at 1:07 pm #1007095Thanks 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_titleis not included?Richard
-
This reply was modified 7 years, 1 month ago by
raslade.
September 9, 2018 at 7:49 pm #1007675Hi,
Can you please make sure you copy it from the forums and not any emails?
Best regards,
BasilisSeptember 9, 2018 at 9:03 pm #1007700OK thanks. I’ve tried the code and getting:
FATAL ERROR syntax error, unexpected '{' on line number 8September 10, 2018 at 7:37 pm #1008045Hey!
I forgot a bracket – I updated the code above – please try it again.Regards,
PeterSeptember 10, 2018 at 9:00 pm #1008074Perfect, thank you for fixing.
Richard
September 11, 2018 at 8:26 am #1008241 -
This reply was modified 7 years, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
