For more how-tos and advice, return to How Do I …?
Q. How do I get FeedWordPress to display only a short summary or excerpt of syndicated posts, instead of the full content?
A. The best way for you to do this is to edit your WordPress template files so as to change what appears in the content section of your Post Loop. (You can edit template files directly from the WordPress administrative interface using Appearance –> Theme Editor, or you can edit them in a text editor on your own computer and upload them to your theme directory.)
The Templates section of the Documentation Wiki documents the template tags that FeedWordPress provides when it is activated; the most important tags for this particular task is is_syndicated()
. What you need to do is identify the Post Loop for your Theme, which typically looks something like this:
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?>
<!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in <?php the_category(', ') ?> | <?php
edit_post_link('Edit', , ' | '); ?> <?php
comments_popup_link('No Comments »', '1 Comment »',
'% Comments »'); ?></p>
</div>
<?php endwhile; ?>
(This example is taken from Kubrick, the default theme for WordPress 2.x. Different themes may have different post loops, but you can almost always identify them by finding while (have_posts()) : the_post()
. In most themes, you will need to find the post loop in the Main Index Template (index.php
), the Archives template (archive.php
), and possibly the Single Post (single.php
) and Search Results (search.php
) templates. Some Themes, in order to avoid duplication, use a different template file, often called post-content.php
or something similar, or a function in the Theme Functions (functions.php
) template, to handle all displaying of post contents.)
Anyway. Once you have found your post loop, you need to replace the template function the_content()
with a code that will take an excerpt and display that. For example, by changing this portion of the loop:
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
To read like this instead:
<div class="entry">
<?php if (is_syndicated()) :
// Strip down to an excerpt
$text = get_the_content(); $text = strip_tags($text);
if (strlen($text) > 255) :
$text = substr($text, 0, 252).'...';
endif;
print $text;
else :
the_content('Read the rest of this entry »');
endif; ?>
</div>
Does that answer your question? If not, use the Talk page to comment on this post or contact me by e-mail for help. Be sure to describe what you are trying to do, and the problems you are running into, with as much detail as possible.
For more how-tos and advice, return to How Do I …?
It worked to clip the content to, for me 800 characters.
BUT – the images disappears! Is there any other way to go around:
For example: http://testdrive.attefall.se/nyheter/create-perfect-emails-for-your-wordpress-website/
I tried implementing both codes (short & long) and neither did anything. I have to assume it’s not recognizing the “is_syndicated()” function. Is there anyway to fix this?
It looks like my syndicated posts are being truncated with […]
I’m sure it has something to do with the excerpt, but I’ll need to dig further. Have you seen this before?
I think I found it – If the blog I’m syndicationg has their settings to only display a summary in a feed that would only allow me to syndicate that blog’s ‘excerpt’.
Correct?
This could be construed as subversive, but is there a way around that?
It’s more about not needing to manage the technical knowledge of the users whose blogs I have consent to syndicate.
Found a tool that works pretty well:
http://fulltextrssfeed.com/
has this changed since this was posted? I can’t seem to find the code it is explaining here.
It would be handy to trim text in the moment of the grabbing. Anyidea for where is the code to be modified int he feedwordpress plugin?
If you want to trim the text when it is grabbed from the feed, the best way to do this would be with a filter on the
syndicated_item_content
hook. (You can use PHP string functions likesubstr
or WordPress templating functions likewp_trim_excerpt