I’m working on a project, that requires people to add excerpt text in a page. By default excerpts are not enabled in WordPress for pages but there is a simple function you can add to your functions.php file to enable Page Excerpts.
Locate you functions.php file in your theme’s directory and add this line of code to it:
1 |
add_post_type_support('page', 'excerpt'); |
Now you will see the Excerpt box below the Content box on your pages. For more information about the add_post_type_support function, check out the WordPress Codex. Have fun!
Very interesting i couldn’t find this simple hint on wordpress.org website. But, one problem I added this an it just doesn’t work. At all. Did I do something wrong? I just copy/pasted this line into my functions.php file. What do you think the issue could be?
Thanks!
jC
Okay. Cool. Figured it out!
The code that’s up there, when you copy/paste it in, it gives you the wrong character codes for ‘page’, ‘excerpt’
So, I replaced those and it worked!
Hope that helps!
– JC
Hi JC,
It probably used smarty-quotes… I’ll fix it so it doesn’t.
Thanks!
Thanks, works great. Simple and useful.
not working for me though i took care of the quote and added a hook as mentioned in the codex
Karol,
If you’re using WP 3.0 or greater, it should work fine. But you may have some code somewhere removing the support too. It’s hard to say without looking at your setup.
Lew
Better do it this way:
if ( function_exists(‘add_post_type_support’) )
{
add_action(‘init’, ‘add_page_excerpts’);
function add_page_excerpts()
{
add_post_type_support( ‘page’, ‘excerpt’ );
}
}
Thanks for this, I was searching on how to add the excerpt to my wordpress fucntions. Thanks
Excellent, thanks for the solution!
Thanks for teaching how to add excerpt manually. Another simple way to add or activate excerpt is to simply go to “Add New Post option” then go to “Scree Options” (lying next to “Help”) and tick the Excerpt box. You’re done.
In Edit mode of page, the Excerpt option doesn’t exist on Screen Options by default, so adding the code into functions.php is necessary
Just wondering how to add excerpt to a specific page instead of all pages?
Hi! How i add the excerpt in the post page? Thanks!
Works great for me, thanks!
I’ve come across plenty of websites explaining this code and it does work, but no one explains how to actually get it to display on a page. I’ve tried the_excerpt() and get_the_excerpt() as I want to just display it below the content on certain pages, but I can’t get it to display anything, despite text being present and saved in that box.
Hi Matthew,
I just tested this on one of my development site, seems to be working fine for me w/ the_excerpt(); Make sure you’re adding the function to the properly theme template.
I could not get it to work with my theme. Spent almost an hour on it. It kept displaying the title of my site, despite me not calling the_title(). I ended up just creating a custom field, entering my own personal message, and calling it that way.
It sounds like you’re not inside the loop… might be a theme issue.
Definitely in the loop.. and right where i want it.. after the content. Could definitely be a theme issue.
kills the php..
if (have_posts()) : while (have_posts()) : the_post();
h1 class=”page-title”>the_title(); /h1
the_content();
the_excerpt(); <-right where i want it — after the content
endwhile;
endif;
That should work… this is what I did in the twenty-twelve theme on my dev site: http://l3w.us/i/12f61e.png that’s in the page.php file.