• On the right sidebar of 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, 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)
  • So far as I know WP has never allowed executable PHP in a text widget. You can create a widget 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

    (@chuckpeters)

    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>

    Widgets are actually very easy in basic structure. You should look into it. Here is a shell 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.