syndicated_item_excerpt

Contents

[ hide ]

    The syndicated_item_excerpt hook allows you to write filters which alter or act on the excerpt for posts that are syndicated by FeedWordPress. The hook passes two parameters to any registered filter functions: a string containing the excerpt for the item (as taken from the syndication feed) and an object of class SyndicatedPost representing the syndicated item as a whole.

    Filter functions should return a string containing the filtered excerpt to be imported into the WordPress database. If the filter returns an empty value, WordPress will generate an excerpt automatically from the post content.

    Sample

    This example filter will ensure that any HTML tags will be stripped out of the excerpts taken from the syndicated feed.

    <?php
    /*
    Plugin Name: FWP+: Strip HTML from syndicated post excerpts
    Plugin URI: http://feedwordpress.radgeek.com/wiki/add-on-strip-html-from-syndicated-post-excerpts
    Description: alters the excerpts for incoming syndicated posts to strip out any HTML provided by the feed
    Version: 2010.1129
    Author: Charles Johnson
    Author URI: http://radgeek.com/
    License: GPL
    
    
    • /


    add_filter( /*hook=*/ 'syndicated_item_excerpt', /*function=*/ 'fwp_strip_excerpt', /*order=*/ 10, /*arguments=*/ 2 );

    /** * fwp_strip_excerpt: Strips HTML from the excerpt for syndicated * posts. * * @param string $excerpt The current excerpt for the syndicated item. * @param SyndicatedPost $post An object representing the syndicated post. * The syndicated item data is contained in $post->item * The syndication feed channel data is contained in $post->feed * The subscription data is contained in $post->link * @return string The new content to give the syndicated item. */ function fwp_strip_excerpt ($excerpt, $post) { // Strip out the HTML $excerpt = strip_tags($excerpt);

    // Send it back return $excerpt; } /* fwp_strip_excerpt() */
    This page is a Wiki! Log in or register an account to edit.

    Leave a Reply

    Your email address will not be published. Required fields are marked *