Javascript,Nodejs,MongodDB,WordPress,CSS,PHP

LightBlog

Tuesday, September 4, 2018

How to show short information

This function trims text to a certain number of words and returns the trimmed text. the simple the_content() function will not work with wp_trim_words use instead of get_the_content() function.this function takes two parameters one is function name and other one is number of words.

 

 

Syntax:


<?php $trimmed wp_trim_words$text$num_words 55$more null ); ?>

$text
(string) (required) Text to trim
Default: None
$num_words
(integer) (optional) Number of words
Default: 55
$more
(string) (optional) What to append if $text needs to be trimmed.
Default: '&hellip;

Example:

<?php

the_title(); // display post title  

echo wp_trim_words( get_the_content(), 40, '...' ); // display post content

?>








No comments:

Post a Comment