the_excerpt()
Dans le fichier functions.php
add_shortcode( 'query_shortcode', 'query_shortcode_function' ); function query_shortcode_function() { $buffer = '<h3>Post Titles</h3>'; $q = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => 5 )); while ($q->have_posts()) { $q->the_post(); $buffer = $buffer.get_the_title().'<br>'; } wp_reset_postdata(); return $buffer; }
Changer ou personnaliser le texte « Read more… »:
/** * Filter the "read more" excerpt string link to the post. * * @param string $more "Read more" excerpt string. * @return string (Maybe) modified "read more" excerpt string. */ function wpdocs_excerpt_more( $more ) { if ( ! is_single() ) { $more = sprintf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( 'Read More', 'textdomain' ) ); } return $more; } add_filter( 'excerpt_more', 'wpdocs_excerpt_more' );
Changer ou personnaliser le symbole en fin de texte tronqué:
/** * Filter the excerpt "read more" string. * * @param string $more "Read more" excerpt string. * @return string (Maybe) modified "read more" excerpt string. */ function wpdocs_excerpt_more_string( $more ) { return ' [.....]'; } add_filter( 'excerpt_more', 'wpdocs_excerpt_more_string' );
Tous les détails à retrouver ici