• Hi,

    I wish to display the output of a PHP contents in WordPress page, but I cannot do that. I can get it displayed in the sidebar, but not in the page.

    I am trying to put the “Recent posts” in a separate page in wordpress.

    Any clues?

    Thanks in advance,

    – U

Viewing 2 replies - 1 through 2 (of 2 total)
  • I expect reading about The Loop will help.

    You’ll also need to link to wp-blog-header.php, something like:

    <?php require('wp-blog-header.php'); ?>

    Put that before any other code.

    PS you won’t be able to call that from within a WordPress page. You’ll have to make a separate .php file.

    Although you could probably edit your “page” template to do it, and wrap all the “recent post” code in this:

    <?php if is_page('recent') {
    /* code goes here (same as what you put in the sidebar, most probably) */
    } ?>

    You could then put that in your content div and create a blank page called “recent”. That might work, it’s a start anyway 🙂

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

The topic ‘PHP code in page contents’ is closed to new replies.