Skip to content

Snippet: Alter The Default Excerpt Arguments

/* The Default arguments look like this:
    $defaults = array(
        'output'        => '',
        'length'        => '30',
        'readmore'      => false,
        'readmore_link' => '',
        'more'          => '…',
    );
*/

// You can use a filter to alter these. It will also override any values inputed for the wpex_get_excerpt() function
function my_wpex_excerpt_args( $args ) {

    // Set more tag to nothing
    $args['more'] == '';

    // Change more tag into a more link for portfolio posts
    if ( 'portfolio' == get_post_type() ) {
        $args['more'] = '…<a href="'. get_permalink() .'" title="'. wpex_get_esc_title() .'">'. __( 'Read More', 'wpex' ) .' →</a>';
    }
    
    // Return args
    return $args;

}
add_filter( 'wpex_excerpt_args', 'my_wpex_excerpt_args' );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top