nowplaying.include.php Will Not Display Results

Cyberchimps.com recommended I post here as they believed there may be a global issue with my request. I thought what I was missing was obvious and simple, but two months into this and being referred here seems to indicate otherwise. All I would like to do is have some results from some very simple php to work either in a sidebar widget or the main page. I know the php is working because I can view it’s results at http://ie107.com/wp-content/themes/responsive-child-theme/nowplaying-example.php. I have tried Allow PHP, Exec-PHP and one other plugin to no avail. I know their plugins work because their samples worked on my site.

The code/instructions are this simple:

Read More
  • To display the artist and title of the current song in any webpage, simply include the following code at the beginning of the page:

    include “nowplaying.include.php”;
    
  • To display the current artist and title, insert the code <?php print htmlspecialchars($GLOBALS["track"][0]["artist"]) ?> and <?php print htmlspecialchars($GLOBALS["track"][0]["title"]) ?> respectively. For example:

    We are currently playing by

Thus far I installed and activated three PHP plugins at separate times. I have relocated the script from the /wp-admin folder to the /wp-content/themes/responsive-child-theme folder as instructed by azoomer.com. I created a text widget and tested the widgets and PHP with <?php echo “This is the PHP ‘Hello World’”; ?> and was successful. I then created a text widget with:

<?php include(ABSPATH. “/wp-content/themes/responsive-child-theme/nowplaying.include.php”); ?>

<?php
include “nowplaying.include.php”;
?>

<p>We are currently playing <?php print htmlspecialchars($GLOBALS["track"][0]["title"]) ?> by <?php print htmlspecialchars($GLOBALS["track"][0]["artist"]) ?></p>

The widget appeared but there was no text at all, not even “We are currently…” I removed <?php include “nowplaying.include.php”; ?> the text “We are currently playing by” appears but no song and artist. I also tried without the absolute path and it did not work either. I verified the song and artist information is being retrieved again by visiting http://ie107.com/wp-content/themes/responsive-child-theme/nowplaying-example.php. I then copied the code from that site source into my widget and only text populated again without song and artist.

Related posts

1 comment

  1. Your script is at /wp-content/themes/responsive-child-theme/nowplaying-example.php but you are including /nowplaying-example.php. That is not going to work. You need to provide the complete path for that include:

    include(get_stylesheet_directory().'/nowplaying-example.php');
    

    Assuming I have read that right, and assuming that the files are actually there.

    Your other code– the widget code– contains curly quotes. Don’t use those. Use ordinary, boring straight up and down quotes like in the first code you posted. That could be causing errors. But that other code also has a bad include. Those bad includes will trigger warnings, which could cause other issues.

Comments are closed.