Support » Fixing WordPress » Customizing the feed template

  • Hi,

    Can anyone out there help me how to customize the RSS feed template because my post format is very different. I don’t use the normal box for content, I uses custom field instead. So I would like to include my custom field content in the RSS feed.

    Is that possible?


Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    Here is a piece of code to point to your own feed template and create an unique feed name.

    function create_my_customfeed() {
    load_template( TEMPLATEPATH . ‘your-custom-feed.php’); // You’ll create a your-custom-feed.php file in your theme’s directory
    add_action(‘do_feed_customfeed’, ‘create_my_customfeed’, 10, 1);

    Now, you will need to modify your feed. You will now be able to access your feed at But what about how WordPress does the really neat rewriting of feeds from /?feed=rss to /feed/rss/? That requires using generate_rewrite_rules(), as described in the WP_Rewrite Codex page.

    This piece of code will allow you to have any feed name, and dynamically “create” /customfeed.xml as well as a /feed/customfeed/ versions:

    function custom_feed_rewrite($wp_rewrite) {
    $feed_rules = array(
    ‘feed/(.+)’ => ‘index.php?feed=’ . $wp_rewrite->preg_index(1),
    ‘(.+).xml’ => ‘index.php?feed=’. $wp_rewrite->preg_index(1)
    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
    add_filter(‘generate_rewrite_rules’, ‘custom_feed_rewrite’);

    In the first piece of code, we told the create_my_customfeed() function to look in your theme’s directory for a your-custom-feed.php file. This will be the feed template your feed will use.


    Shane G.

    I guess you didn’t get want I meant.

    I wanted to include the custom field value into my CSSFEED, my content box is blank.

    I guess you didn’t get want I meant.

    I wanted to include the custom field value into my rss feed**, my content box is blank.



    Shane, thank you for the code, it seems to be exactly what I’m looking for (my goal is to output everything as XML for the purpose of importing it and using it in a Flash frontend).

    But I wasn’t sure about where to put it.

    Where does the above code go?

    @somwthingclassy: the code should go into functions.php of your theme

    Hi, I have wordpress 2.9.2
    I have implemented the code just like you say in my template function.php, and created my template “custom-feed.php” and uploaded both file in my theme folder. But I keep getting this error:

    Warning: require_once(/home/magawork/public_html/criaturas/wp-content/themes/Infinitycustom-feed.php) [function.require-once]: failed to open stream: No such file or directory in /home/magawork/public_html/criaturas/wp-includes/theme.php on line 996

    In lines 990 to 997 of this file “../wp-includes/theme.php” I have this code:
    function load_template($_template_file) {
    global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;

    if ( is_array($wp_query->query_vars) )
    extract($wp_query->query_vars, EXTR_SKIP);


    Can anyone help me with this error? I am not a php programmer so I have no idea what this means.

    magaworks, I ran into this same issue. You need to add a ‘/’ in front of your custom wordpress feed file. So this:
    load_template( TEMPLATEPATH . 'your-custom-feed.php');

    load_template( TEMPLATEPATH . '/your-custom-feed.php');

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Customizing the feed template’ is closed to new replies.