WordPress.org

Ready to get started?Download WordPress

Forums

Code Insertion (7 posts)

  1. noktis
    Member
    Posted 6 years ago #

    I am trying to insert code, and it keeps dropping information. I think that this is why it won't display properly. These are surrounded in the proper code tags with dogears around it.

    <?PHP srssfetcher('http://news.google.com/news?hl=en&ned=us&q=%22my+search%22&ie=UTF-8&output=rss', 20, true, true, true); ?>

    BECOMES

    <!--P srssfetcher('http://news.google.com/news?hl=en&ned=us&q=%22my+search%22&ie=UTF-8&output=rss', 20, true, true, true);-->

  2. noktis
    Member
    Posted 6 years ago #

    I just noticed, it's not fetcher that's working as a widget, that's broken as well. I guess it must be something with the widget. Anyway, is there a way to get the core RSS feed widget to dump out to the main body of a page?

  3. slate62
    Member
    Posted 6 years ago #

    WP destroys my code all the time.

  4. Michael Torbert
    WordPress Virtuoso
    Posted 6 years ago #

    WordPress will strip out certain tags, like PHP, divs, etc in pages and in posts. http://wordpress.org/extend/plugins/exec-php/ is a great plugin for allowing you to keep your PHP code in posts.

    The following code will dump your rss feed.

    <?php
    $file = fopen("http://yourdomain.com/rss", "r");
    while ( ! feof($file) ) {
    $text = fgets($file);
    ?>

  5. <?php echo $text;?>
  6. <?php } ?>

    Replace http://yourdomain.com/rss with whatever the path to your wordpress feed is.

  • Michael Torbert
    WordPress Virtuoso
    Posted 6 years ago #

    Sorry, the forum stripped some of my code, although nothing important. But you get the idea. Let me know if this helps.

  • moshu
    Member
    Posted 6 years ago #

    forum stripped some of my code

    Use the "code" button... that's why it is there: highlight your code and click on that freakin' button!

  • Michael Torbert
    WordPress Virtuoso
    Posted 6 years ago #

    Thanks Moshu. I realized it after. :)
    It only took out my li tags as far as I could tell though, which weren't vital, just made it look better.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags