WordPress.org

Forums

[resolved] display post titles in web page (4 posts)

  1. cheaper
    Member
    Posted 10 years ago #

    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

  2. planetthoughtful
    Member
    Posted 10 years ago #

    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]

  3. planetthoughtful
    Member
    Posted 10 years ago #

    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]

  4. cheaper
    Member
    Posted 10 years ago #

    Hey
    That was Fantastic thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags