0

I had successfully created shortcode on my wordpress website to use it in the posts. But I later realised that it is breaking my rss-feed.

Here is the shortcodes.php

<?php
function disclaimer() {
    $disc = "&nbsp;<p style='font-style:italic;'> <strong>Disclaimer</strong> :</p>";
    return $disc;

}
add_shortcode('disclaimer', 'disclaimer');
?>

Here is how I am including it on the functions.php

<?php

include 'shortcodes.php';

So now, I am getting this error when I access my rss URL on my browser enter image description here

So when I removed this include 'shortcodes.php'; my rss feed started working. But then I also want my shortcode to work. Am I doing anything wrong here? Any help would be highly appreciated.

Venkateshwaran Selvaraj
  • 1,745
  • 8
  • 30
  • 60
  • 1
    Works ok for me... try to remove the closing `?>` from shortcodes.php, it's not necessary and if there's any character after it [some things may break](http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag) – brasofilo Jun 04 '14 at 09:55

1 Answers1

0

You can change your function so that the disclaimer is not added on feed page

function disclaimer() {
    if ( ! is_feed() ) {
        $disc = "&nbsp;<p style='font-style:italic;'> <strong>Disclaimer</strong> :</p>";
        return $disc;

    }
}

Edit:

Then it is not a problem with the code, but some problem with the file.

Make sure there is not extra space after the closing ?> php tag. Or better, try to remove it completely.

Sudar
  • 18,954
  • 30
  • 85
  • 131