Support » Developing with WordPress » How to edit the rss/feed output

  • I’m using the standard wordpress rss. I’d like to remove the author from the output, but how?

    The output now is:
    Titel
    time, date, author, tags
    site name
    content article

Viewing 7 replies - 1 through 7 (of 7 total)
  • The simplest way is using CSS. Add this to your Additional CSS:

    .widget_rss cite { display: none; }

    Thread Starter ronaldb73

    (@ronaldb73)

    I don’t mean the rss output in a widget, but my own rss-feed as used for rss-readers.

    @ronaldb73 Sorry for misunderstanding. I have a solution.

    The output of rss2 is located at wp-includes/feed-rss2.php. There is no filter to hide the <dc:creator> tag (this is author tag).

    But that file is included from do_feed_rss2() function which hooked to do_feed_rss2 action, so you can add your own do_feed_rss2 function to include your custom feed output file.

    Step 1: Copy file wp-includes/feed-rss2.php to your plugin, then remove <dc:creator>.
    Step 2: Add the code below to your plugin, remember to change the file path:

    
    remove_action( 'do_feed_rss2', 'do_feed_rss2', 10 );
    
    function prefix_do_feed_rss2( $for_comments ) {
    	var_dump($for_comments);
    	if ( $for_comments )
    		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
    	else
    		load_template( plugin_dir_path( __FILE__ ) . 'feed-rss2.php' ); // Change to your own file path.
    }
    add_action( 'do_feed_rss2', 'prefix_do_feed_rss2' );
    

    Step 3: Check the rss output. Use Ctrl + F5 if it doesn’t work.

    Thread Starter ronaldb73

    (@ronaldb73)

    thanks for trying to help me out here, much appreciated. But what plugin do you mean?
    And I just removed the line with dc:creater but the user/author is still shown.

    I mean adding that code to your theme or plugin which you are developing. I tested by adding it to hello dolly plugin and it works. Remember to use Ctrl + f5 to refresh the feed page (http://yourdomain/feed/)

    Thread Starter ronaldb73

    (@ronaldb73)

    well, it worked, but it turned out not the solution I needed. I thought our feed was the basis for our Android App, and I wanted to remove the author from the app. I know learn the app uses the WordPress Api to fetch the articles and pictures and all. Is there a way to edit the API?

    Moderator bcworkz

    (@bcworkz)

    The REST API in most cases is filterable. You can filter the returned values, removing the undesirable portions. You must not directly edit the API code however. In general the filter to use is “rest_post_dispatch“. Once you hook this filter, all public properties and methods of the WP_REST_Response object are accessible.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to edit the rss/feed output’ is closed to new replies.