Tagged: , , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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

    #1007008

    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

    #1007095

    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

    • This reply was modified 5 years, 7 months ago by raslade.
    #1007675

    Hi,

    Can you please make sure you copy it from the forums and not any emails?

    Best regards,
    Basilis

    #1007700

    OK thanks. I’ve tried the code and getting:

    FATAL ERROR syntax error, unexpected '{' on line number 8

    #1008045

    Hey!
    I forgot a bracket – I updated the code above – please try it again.

    Regards,
    Peter

    #1008074

    Perfect, thank you for fixing.

    Richard

    #1008241

    Hi,

    Glad we could help :-)

    Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

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