syndicated_item_author

Contents

[ hide ]

    The syndicated_item_author hook allows you to write filters which alter or act on the author of posts that are syndicated by FeedWordPress. The hook passes two parameters to any registered filter functions: an array representing known meta-data for the author of the current post, and an object of class SyndicatedPost representing the syndicated item as a whole.

    The array passed as the first parameter has the following format:

    • $author[1] contains the plain text name given for the author. If the feed does not provide a name, a name is generated based on the e-mail, feed title, or feed URL.

    • $author[2] contains the e-mail address, if any, provided for the author of this post. (Note that many feeds do not provide an e-mail address for post authors, or provide a false address, in order to deter spam.) You should not be surprised if this field is empty or contains an unreliable value.

    • $author[3] provides a URL for the author’s human-readable homepage, or is left empty, if none was provided.

    Sample

     <?php
     /*
     Plugin Name: FWP+: Use Source Name for Author Name
     Plugin URI: http://feedwordpress.radgeek.com/wiki/fwp-use-source-name-for-author-name
     Description: alters the authors of incoming syndicated posts to use the source feed name for the author's name
     Version: 2010.1108
     Author: Charles Johnson
     Author URI: http://radgeek.com/
     License: GPL
     */
    

    add_filter( /*hook=*/ 'syndicated_item_author', /*function=*/ 'fwp_use_source_name_for_author_name', /*order=*/ 10, /*arguments=*/ 2 );

    function fwp_use_source_name_for_author_name ($author, $post) { // See if we can get the source feed's title $name = $post->link->name();

    // If we got it, write it to the author's name if (strlen($name) > 0) : $author[4] = $name; endif;

    // Send it back return $author; }
    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 *