Support » Fixing WordPress » display post titles in web page

  • Resolved cheaper

    (@cheaper)


    Hello
    I am trying to get the post titles to dispay on my main web page using perhaps php with mysql.

    Idealy i would need say last 5 posts titles displayed with bullet and the page links.

    Is there anyone out there who could help with the php sql coding.

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi cheaper,

    Can you give me a link to your WP blog, so I can check the URL format you’re using?

    Much warmth,

    planetthoughtful

    [Moderated. ‘Signatures’ in posts are not permitted as they are impossible to police in terms of size, contents and links. It is appreciated if they would not be used.
    Thank you. – Podz]

    Actually, don’t worry, I found it via one of your other posts.

    Try:


    <?php
    $SQL = "SELECT ID, post_title FROM wp_posts ORDER BY post_date DESC LIMIT 5";
    $rs = mysql_query($SQL);
    echo "<ul>";
    while ($row = mysql_fetch_object($rs)){
    echo "<li><a href='http://www.cheaperholidays.com/late-deals/?p={$row->ID}'>{$row->post_title}</a></li>";
    }
    echo "</ul>";
    mysql_free_result($rs);
    ?>

    Simply drop that on the page where you would like to see the 5 most recent post titles and it should provide them for you.

    Hope this helps.

    Much warmth,

    planetthoughtful

    [Moderated. ‘Signatures’ in posts are not permitted as they are impossible to police in terms of size, contents and links. It is appreciated if they would not be used.
    Thank you. – Podz]

    Hey
    That was Fantastic thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘display post titles in web page’ is closed to new replies.