WordPress.org

Forums

& in syndicated link (5 posts)

  1. murky
    Member
    Posted 8 years ago #

    Hi,

    At http://www.murky.org/UKPoliBlog I have a syndicated site, (made of feeds)

    The issue is that & appears in the links, which invalidates the feeds for each column.

    The fix is to change & to &amp;, but as I don't directly control the links this needs to be done automagically, ideally <?php permalink_single_rss(); ?> would have a filter which replaced & with &amp; in links (not replacing &amp; with &amp;amp; of course!)

    Does anyone know how I can achieve this?

  2. murky
    Member
    Posted 8 years ago #

    A fix... now, how do I submit this as a patch?

    In the file:

    feed-functions.php

    the permalink_single_rss() function needs updating:

    function permalink_single_rss($file = '') {
    $url = get_permalink();
    $url = str_replace("&", "&amp;", $url);
    $url = str_replace("&amp;amp;", "&amp;", $url);
    echo $url;
    }

    Now to find the error in the link to comment feeds....

  3. murky
    Member
    Posted 8 years ago #

    In the file comment-functions.php

    function comments_link( $file = '', $echo = true ) {
    $url = get_comments_link();
    $url = str_replace("&", "&amp;", $url);
    $url = str_replace("&amp;amp;", "&amp;", $url);
    }

  4. murky
    Member
    Posted 8 years ago #

    Finally, in feed-functions.php :

    function comments_rss($commentsrssfilename = '') {
    global $id;

    if ('' != get_settings('permalink_structure'))
    $url = trailingslashit( get_permalink() ) . 'feed/';
    else
    $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;p=$i
    d";
    $url = str_replace("&", "&amp;", $url);
    $url = str_replace("&amp;amp;", "&amp;", $url);

    return apply_filters('post_comments_feed_link', $url);
    }

    I'd really like to submit these as possible patches (if nothing else it'll prevent recurrence in the future), any clues?

  5. murky
    Member
    Posted 8 years ago #

    OOps, should have been:

    function comments_link( $file = '', $echo = true ) {
    $url = get_comments_link();
    $url = str_replace("&", "&amp;", $url);
    $url = str_replace("&amp;amp;", "&amp;", $url);
    echo $url;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic