WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode Exec PHP
[resolved] a beginner's question - php does not work (5 posts)

  1. Frank5189
    Member
    Posted 1 year ago #

    The purpose is to display RSS (e.g. BBC news) content on a wordpress page. I have put the following code into the short code box and test it. It gave me a 'Error 500'

    Maybe it is the path wrong.

    Thank you for your help!

    ----------------

    <?php
    include_once(ABSPATH.'wp-content/plugins/rss.php'); // path to include script
    $feed = fetch_rss('http://feeds.bbci.co.uk/news/rss.xml'); // specify feed url
    $items = array_slice($feed->items, 0, 7); // specify first and last item
    ?>

    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item) : ?>

    <h2>"><?php echo $item['title']; ?></h2>
    <p><?php echo $item['description']; ?></p>

    <?php endforeach; ?>
    <?php endif; ?>

    -----------

    http://wordpress.org/extend/plugins/shortcode-exec-php/

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    Start with removing the PHP tags, see also the FAQ.

  3. Frank5189
    Member
    Posted 1 year ago #

    thank you for such speedy reply.

    Here is the code without the php tags: it still gives me the same error.

    More help please, thank you.

    ---
    include_once(ABSPATH.'wp-content/plugins/rss.php'); // path to include script
    $feed = fetch_rss('http://feeds.bbci.co.uk/news/rss.xml'); // specify feed url
    $items = array_slice($feed->items, 0, 7); // specify first and last item

    if (!empty($items)) :
    foreach ($items as $item) :

    <h2>
    echo $item['title'];
    </h2>
    <p> echo $item['description']; </p>

    endforeach;
    endif;
    ---

  4. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry, but this won't work. I can only help you if you somewhat understand what you're doing (no offence meant). Simply removing the PHP tags leaves a mix of PHP and HTML.

  5. whalleh
    Member
    Posted 1 year ago #

    Hello, I already tested the php code but I don't know how to insert it into my page. Pls help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags