Sillybean

Post and Page Excerpt Widgets

Creates widgets that display excerpts from posts or pages in the sidebar. You may use ‘more’ links and/or link the widget title to the post or page. Based on Milan Petrovic’s Multi Instance Widget. Requires Page Excerpt or Excerpt Editor for page excerpts. Supports the_excerpt Reloaded and Advanced Excerpt.

Download »

If you’d rather not use a widget, here’s the more or less equivalent code for your template (which does not require you to install this plugin).

For pages:

<?php
	// page title
	echo = '<a href="'.get_permalink($post->ID).'">'.the_title().'</a>'; 
	// custom Loop
	$page_query = new WP_Query('page_id='.$post->ID); 
	while ($page_query->have_posts()) : $page_query->the_post(); 
	// the excerpt of the page
	if (function_exists('the_excerpt_reloaded')) 
		the_excerpt_reloaded(100, '<p><div><span><br><img><a><ul><ol><li><blockquote><cite><em><i><strong><b><h2><h3><h4><h5><h6>', 'content', FALSE, '', '', '1', '');
	else the_excerpt(); // this covers Advanced Excerpt as well as the built-in one
	endwhile; // end custom Loop
?>

For posts, the query is slightly different:

<?php
	// page title
	echo = '<a href="'.get_permalink($post->ID).'">'.the_title().'</a>'; 
	// custom Loop
	$post_query = new WP_Query('p='.$post->ID); 
	while ($post_query->have_posts()) : $post_query->the_post(); 
	// the excerpt of the page
	if (function_exists('the_excerpt_reloaded')) 
		the_excerpt_reloaded(100, '<p><div><span><br><img><a><ul><ol><li><blockquote><cite><em><i><strong><b><h2><h3><h4><h5><h6>', 'content', FALSE, '', '', '1', '');
	else the_excerpt(); // this covers Advanced Excerpt as well as the built-in one
	endwhile; // end custom Loop
?>
20 comments

Sharing this post? The short URL is http://sillybean.net/?p=1555

20 Responses to “Post and Page Excerpt Widgets”

  1. [...] few cool new WP plug-ins Found some cool new WP plug-ins – check ‘em out: Post and Page Exerpts Page to Post/Post to Page Converter Show or hide content from bots Internal Link building [...]

  2. [...] Post and Page Excerpt Widgets [...]

  3. Leonaut.com says:

    Post and Page Excerpt Widgets…

    Creates widgets that display excerpts from posts or pages in the sidebar. You may use

  4. Umesh says:

    Thanks for the plugin. It can be very usefull. But somehow it shows the excerpt and below full post. What can I do with that?

  5. Thanks for the plugin! I need to include a page excerpt on a custom landing page and am wondering if there is a php function I can call instead of using the widget interface? I’m using Excerpt Editor to generate the page excerpt.

  6. Stephanie says:

    You’d use the_excerpt as usual, but you need to be inside a loop for the appropriate post/page ID, and in most cases that will mean adding a second loop to the template. I’ve edited the page to include the code that prints the title and excerpt inside a custom loop for both posts and pages.

  7. ElShaddai Edwards says:

    Is there any way for this plug-in to display the N most recent excerpts rather than a specific ID?

    I need to be able to display excerpts of the last 2 or 3 blog posts on a static page template (not single post or index), either by widget or code, and have not been able to find a way to do this.

  8. Stephanie says:

    This plugin doesn’t do that, but I have the code that does and will release it as a plugin later this week.

  9. ElShaddai Edwards says:

    Thanks for the reply – I found a serviceable solution for the time being, but will look forward to yours as well!

  10. baby blog says:

    hey, good plugin. The page excerpt is not working properly on my blog (wp v2.8.3). The more.. link is not showing. It shows [..] instead and with no link to the page.

    • Stephanie says:

      Have you upgraded to the latest version of the plugin? I fixed one problem with the more links. If you have, do you have any plugins (like the_excerpt reloaded, or advanced excerpt) that affect the excerpts?

  11. Lynne says:

    I am having the same problem as baby blog…more link not working.
    I have the most current Verizon of the plugin from wp extend…and am using wp v2.8.3.
    I have no other plugins that might affect excerpts. The more link was working fine before upgrade.

  12. Lynne says:

    just a heads up…based on firebug..it is not inserting the link…

  13. Lynne says:

    Is anyone else having issues with the link to title and the more links since upgrading to wp v2.8.3?

    My more link did not work…so I thought I would just link the title…but they don’t go to the right pages…

  14. Stephanie says:

    Lynne, can you post a link? I’d like to take a look at what’s going on.

  15. Stephanie says:

    Version 2.1 is out now and should solve the problems Lynne and baby blog reported. Huge thanks to Lynne for helping me test this release!

  16. bluantinoo says:

    Really useful plug in, especially in seo/sem cases when you need to optimize landing pages.

    I would like to show a thumbnail (that in my case is the post meta “thumb”) with the excerpt.

    Have you got an idea how to do that?

  17. Stephanie says:

    bluantinoo, I’m planning to implement (optional) thumbnails using the new built-in the_post_thumbnail feature. It’ll be in a new version soonish.

Leave a Reply

Textile formatting is in effect.