I cant seem to work this out...

Discussion in 'PHP' started by richkid, Nov 21, 2007.

  1. #1
    I have just created a custom wordpress layout and added a 'most popular posts' section in.

    website: www.thomassinfield.com


    but the thing is the links are not being created with the correct link structure. It is linking to this:

    http://www.thomassinfield.com/2007/11/15/5-reasons-why-you-will-fail-at-blogging

    when it should be linking to this:

    http://www.thomassinfield.com/blogging/5-reasons-why-you-will-fail-at-blogging


    and the section of code they give you to input doesnt seem to have a way to change it:

    Does anyone know how to fix this?

    thanks
    tom
     
    richkid, Nov 21, 2007 IP
  2. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:
    
    <?php
    $sql = "SELECT post_date, post_title, post_name, comment_count from wp_posts ORDER BY comment_count DESC LIMIT 7";
    $searches = $wpdb->get_results($sql); 
    echo '';
    foreach ( $searches as $searchz ){
    $dtp = explode(" ", $searchz->post_date);
    echo '<li>
    <a href="http://www.thomassinfield.com/' . $searchz->post_name . 
    '" title="' . $searchz->post_title . '">' . $searchz->post_title . '</a></li>';
    }
    
    ?>
    
    Code (markup):
     
    tamen, Nov 21, 2007 IP
  3. richkid

    richkid Well-Known Member

    Messages:
    1,684
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    140
    #3
    hi,
    thanks that is close... i just need to add category infront of post title... do you know how i do this?
     
    richkid, Nov 21, 2007 IP