Support » Themes and Templates » How do I change "the_content( )" to "tamplate tag, the excerpt( )"?

  • I had read the instruction about “How do I show a summary rather than the full content of posts?” & “How do I show an excerpt, teaser, or summary, for an article on the site homepage?” and tried to do it myself. When I go to my wp admin panel, i only find the index.php code like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Would anybody please tell me how I can find the “the_content( )” and change it?
    Thank you for helping

Viewing 3 replies - 1 through 3 (of 3 total)
  • First of all, there’s a way of producing a teaser without altering any code. Just enter a ‘more’ tag into your post at the point where you want the post content to end when it’s displayed as a list. You enter a ‘more’ tag into your post by editing the post, putting the insert cursor at the point in the post where you want it to break, and clicking on the ‘more’ tag button (just to the right of the ‘unlink’ button) in the visual post editor.

    If you really want to use the_excerpt instead of the_content, you need to find the template or other PHP file that is outputting the list of posts and change the_content() to the_excerpt(). Which file this is will depend on the theme you are using. It may also be more than one file, depending on how your theme is structured and whether you just want this to happen on your front page or not. You may even have to create a suitable file – again depending on what your them provides.

    You should also be aware that the_excerpt() strips all html out of the content before displaying it. This may not be what you want.

    By default, only the first 50ish words of a post are shown on a list anyway IIRC.

    If you want a summary that is something other than the first few words or sentences of a post, you’ll need more help than I can give you here.



    Thank you Peredur. Your answer is very helpful. Would you please give me a step by step guide for setting up that? I’m using wp default theme twenty eleven theme. I only have three pages on my site which is Home, About, and Contact. Do I need to add a ‘blog’ page to put my content on and leave the Home page for content summary? I had tried to do it. I put the content in the Blog page successfully. But do you know what is on the Home page? Only one word on the top HOME. It’s really a big job for me. I’ll appreciate if you can help me for this. Looking forward to hear from you again.

    I’m not quite sure what you want instructions on. If you want to use the ‘more’ tag, just click on the button with your insert cursor at the position on the page where you want the teaser to stop.

    If you want to use the_excerpt() instead of the_content() then you need to alter the WP loop code. Since you’re using twenty eleven you simply must do this in a Child Theme.

    If that’s what you’re doing, post back when you have a minimal child theme that behaves exactly like twenty eleven—that is, your child theme directory will contain nothing except a style.css file with the following content:

    • The required comment at the top of the file
    • A single @import url('../twentyeleven/style.css'); command immediately after the comment, and nothing else.

    By default, your blog page will contain your recent posts, and will be your front page. If you want to change that behaviour you have to do a bit of setting up.

    Post back letting us know what you want to do and how you’re getting on.



Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I change "the_content( )" to "tamplate tag, the excerpt( )"?’ is closed to new replies.