Get a limited, character (text) from a wordpress post

There are two way to get limited character

1. First way

<?php wp_trim_words( $text, $num_words = 55, $more = null ); ?>

The parameter break down:

$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: '…'

2. Second Way

In function we can get post content without image

$content = get_the_content();
echo substr($content, 0, 25);

how to get post data from post id in wordpress

We can fetch post data from wordpress database by using wordpress function

get_post ( int|WP_Post|null $post = null, string $output = OBJECT, string $filter = 'raw' )

// get post title name by post id
$post_7 = get_post( 7 );
$title = $post_7->post_title;

// Get post data by using post id
$post = get_post( 42 );
$output = apply_filters( 'the_content', $post->post_content );

// Array of get_post function contain there fields

WP_Post Object
(
[ID] =>
[post_author] =>
[post_date] =>
[post_date_gmt] =>
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] =>
[comment_status] =>
[ping_status] =>
[post_password] =>
[post_name] =>
[to_ping] =>
[pinged] =>
[post_modified] =>
[post_modified_gmt] =>
[post_content_filtered] =>
[post_parent] =>
[guid] =>
[menu_order] =>
[post_type] =>
[post_mime_type] =>
[comment_count] =>
[filter] =>
)

BackWPup Free – WordPress Backup Plugin

We can take fully automatic backup of your website. It’s totally depending on you which content need to take backup. This is absolute free backup.

BackWPup Free of charge enable you to save your valuable comprehensive installation including /wp-content/ as well as press those to a good exterior Back-up Support, just like Dropbox, S3, FILE TRANSFER PROTOCOL and many other, notice number underneath. Which has a sole backup. squat document it is possible to quickly re-establish a good installation.

We got this blog from www.wordpress.org for blog more information Click Here