WordPress.org

Forums

Show latest sub-page under page (4 posts)

  1. ronniebrown
    Member
    Posted 7 years ago #

    Hi

    I have a new site under development where the front page currently shows a Page with a list of child Sub-Pages. I am attempting to have this page show the content of the most recently created Sub Page, instead of what it's currently showing.

    I've tried the following:

    <?php
    
      $how_many=1; //How many posts do you want to show
      require_once('wp-config.php'); // Change this for your path to wp-config.php file ?>
    
      <?
    
        $news=$wpdb->get_results("SELECT * FROM $wpdb->posts WHERE <code>post_parent</code>=\"3\" ORDER BY id DESC LIMIT $how_many");
    
        foreach($news as $np){
    
          printf ("<h1>%s</h1>%s", $np->post_title, $np->post_content);
    
        }
    
    ?>

    This gives me what I want but what is returned is just plain text (with no formatting) unlike what I see if I visit the page in question (<p> tags etc).

    I don't really want to be creating my own query strings so could someone point me in the direction of an already created function that may solve my problem?

    Thanks in advance

    Ronnie

  2. ronniebrown
    Member
    Posted 7 years ago #

    Hi

    Is anyone able to help with this problem?

    It'd be much appreciated.

    Thanks

    Ronnie

  3. ronniebrown
    Member
    Posted 7 years ago #

    Hey

    Anyone think of a solution to this problem? It's driving me nuts?

    :)

    Ronnie

  4. ronniebrown
    Member
    Posted 7 years ago #

    Hi

    Anyone WordPress gurus had a chance to look into this one?

    I will not let it die! ;)

    Ronnie

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.