WordPress.org

Support

Support » Plugins and Hacks » Shortcode Exec PHP » [Resolved] a beginner's question – php does not work

[Resolved] a beginner's question – php does not work

  • 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/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor M66B

    @m66b

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

    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;

    Plugin Contributor M66B

    @m66b

    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.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] a beginner's question – php does not work’ is closed to new replies.
Skip to toolbar