I have the following front-page template made:
In place of those large Lorem Ipsum blocks, I need to show an “excerpt” from a specific page to fill that box (a certain number of characters).
How do I get a pages content in String format so that I can echo it out and trim down to a certain number of characters?
Here you go !
from https://developer.wordpress.org/reference/functions/get_post/
you can use this code it is work fine
change page_id=19 with your page number:
If you’re in the loop do this:
Or if you have an ID, get the post then sue the post_excerpt member var
e.g.
Try this code and just change your
page_id
:For one liner addicts like me. Change 69 by your page ID.
Can do this with a shortcode. add the following to function.php
To render within content use;
Just need to mod the “Lorem ipsum dolor ………” for the length required. And the lorum repeat=2 change to the required amount of paragraphs. In the above example =2 means 2 paragraphs, so its multifuctional.
Already answered but i think a much more handier function is get_post_field( ‘fieldname’, $post_id );
So in your case: