WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] To display post with limited character on home page (2 posts)

  1. @Raj
    Member
    Posted 1 year ago #

    Hi everyone,
    I want to display post on home page with only few words there, if anyone wants to read it more then he/she can click to read more button, but the problem is that i am not able do display a small post my code is displaying the full post which is looking very worst there. please if anybody have an idea please let me know.....
    code that i am using;

    <?php $my_postid = 27;
                            $content_post = get_post($my_postid);
                            $content = $content_post->post_content;
                           	echo $content; ?>
  2. Marventus
    Member
    Posted 1 year ago #

    Hi.
    You would need to use the_excerpt() function for that from your index.php file, which controls the layout of your home/front page.
    More info here.
    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic