• lolo92

    (@lolo92)


    Hi

    I’d like to send the feed with custom content : for example I don’t want the full article to be inserted in the idem <description> but something else like a custom field.

    Could I have a clue on that, where shall I should start ?

    Thanks a lot !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ntm

    (@ntm)

    podPress does not modify the <description>-element of <item>-elements of RSS feeds. It is only possible to modify the <description>-element of the channel (RSS) or subtitle (ATOM) with podPress.

    But WP includes two ways to modify these <description> elements:
    – You can choose in the Reading Settings section of your blog whether it should contain the Full Text of the post or a summary.
    – You could use the excerpt box below the post editor. If you write something into this box it will be automatically the content of the <decription> element of the Feed <item>s.

    If you want to modify or filter the content of <description>-elements of the <item>s in combination with a custom field then you may use a filter plugin which uses the WP Filter Hook ‘the_excerpt_rss’. (Although the name suggests it otherwise this hooks works for the equivalent of the <description> element of the ATOM Feeds, too.)
    Maybe there is already a plugin which makes what you want to achieve.

    But if you are technical minded then you may write your own filter plugin. It is maybe not that difficult.

    I would do it like this:

    <?php
    /*
    Plugin Name: my personal feed element filter
    Plugin URI:
    Description: filters the post content in the feeds
    Author: my name
    Version: 1.0
    Author URI:
    */
    
    add_filter('the_excerpt_rss', 'pff_modify_excerpt');
    function pff_modify_excerpt($description_content) {
    	// get the ID of the current post
    	$post_id = get_the_ID();
    
    	// get all values of the custom field(s) with this custom field name of a current post (see https://codex.www.ads-software.com/Function_Reference/get_post_custom_values for more info)
    	$customfieldvalues = get_post_custom_values('insert here the name of custom field', $post_id);
    	if ( TRUE == is_array($customfieldvalues) ) {
    		// if the current post has at least one custom field with this name then put the contents together as the new description content
    		foreach ( $customfieldvalues as $key => $value ) {
    			if ( FALSE == empty($value) ) {
    				$new_description_content .= $value;
    			}
    		}
    		// if the new description content is not empty then replace the current content with the new one
    		if ( FALSE == empty($new_description_content) ) {
    			$description_content = $new_description_content;
    		}
    	}
    	return $description_content;
    }
    ?>

    Put this code into a file with file name extension .php and store this file in the plugins folder of your blog (e.g. /wp-content/plugins/). Replace insert here the name of custom field with the custom field name you like to use.

    This way you could write also filters for other sub elements of <item>s (or <entry>s).
    podPress (especially the upcoming version 8.8.8) has mainly possibilities to modify the channel elements and it adds of course the <enclosure> elements (and in RSS feeds the itunes elements) to the <item>s (and <entry>s).

    Regards,
    Tim

    Thread Starter lolo92

    (@lolo92)

    Thanks a lot, I didn’t remember about using resume in rss feeds…

    And I’ll give a try at your script, I can type some PHP ??

    Thanks again !

    Regards
    Laurent

    Plugin Author ntm

    (@ntm)

    Hi Laurent,

    I have a further note on that topic:
    podPress adds of course the <itunes:summary> and <itunes:subtitle> elements to RSS <item> elements and these elements contains by default also the post content. But it is possible to edit the content of these elements for each post (see “Post specific settings for iTunes” below the post/page editor). But there is no filter hook for these elements.

    Regards,
    Tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: podPress] Customize feed fields’ is closed to new replies.