Title: sidebar text/html widget does not allow php include
Last modified: August 19, 2016

---

# sidebar text/html widget does not allow php include

 *  [chuckpeters](https://wordpress.org/support/users/chuckpeters/)
 * (@chuckpeters)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/sidebar-texthtml-widget-does-not-allow-php-include/)
 * On the right sidebar of [http://starryskies.net/](http://starryskies.net/) I 
   am trying to have a “More News” list of stories. Prior to the widgets thing I
   coded it in the sidebar.php using something like get_posts(‘numberposts=20&offset
   =20’);.
 * Now I have been trying to include,
    [http://starryskies.net/headlines-w-20-offest-output.php](http://starryskies.net/headlines-w-20-offest-output.php),
   the stories with a text/html widget using the following code.
    -  <?php include ($_SERVER[‘DOCUMENT_ROOT’].’/headlines-w-20-offest-output.php);?
      >
 * I haven’t found any documentation saying this why it doesn’t work… I was planning
   on running this script via cron because it looks like it takes 1.5-2 seconds 
   to run this get_posts script and that would certainly slow things down if it 
   ran every time the sidebar is displayed.
 * How can I get this More News list to work in the sidebar?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/sidebar-texthtml-widget-does-not-allow-php-include/#post-1327532)
 * So far as I know WP has never allowed executable PHP in a text widget. You can
   [create a widget](http://codex.wordpress.org/Widgets_API) and run all the PHP
   you want though, or run something like PHPExec.
 * Maybe its just me but I don’t think that query should be taking 1.5 seconds. 
   I’ve done much more complicated stuff much quicker than that even on my intentionally
   slow local server.
 *  Thread Starter [chuckpeters](https://wordpress.org/support/users/chuckpeters/)
 * (@chuckpeters)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/sidebar-texthtml-widget-does-not-allow-php-include/#post-1327723)
 * Well one of these days I’ll research how to do a widget… Writing a widget seem
   like too much work for this. Someone must have done a widget that would work 
   for this. Searching for one has just been a waste of time. Anyone know of one?
 * For the time being I did the old thing of modifying sidebar.php, thus it will
   get blown away next wordpress update.
 *     ```
       $ diff -u sidebar.php sidebar.php-2.9
       --- sidebar.php 2010-01-03 05:14:29.923688368 -0500
       +++ sidebar.php-2.9     2009-12-30 05:04:03.699148551 -0500
       @@ -79,10 +79,5 @@
   
                               <?php endif; ?>
                       </ul>
       -
       -                        <h2>More News</h2>
       -                                <ul>
       -                                <?php include ($_SERVER['DOCUMENT_ROOT'].'/headlines-w-20-offest-output.php'); ?>
       -                                </ul>
       -
               </div>
       ```
   
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/sidebar-texthtml-widget-does-not-allow-php-include/#post-1327728)
 * Widgets are actually very easy in basic structure. You should look into it. [Here is a shell](http://wordpress.pastebin.com/f2e6b2086)
   I posted for someone else.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘sidebar text/html widget does not allow php include’ is closed to new
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/sidebar-texthtml-widget-does-not-allow-php-include/#post-1327728)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
