Need Wordpress help with php query for featured image and custom field

Discussion in 'Programming' started by s2kinteg916, Jun 24, 2011.

  1. #1
    I need someone to modify the code below. Im using a php file to grab wordpress post and display it on a external page.

    It currently give me results with
    title
    post content
    post link
    post date

    I need added the post thumbnail and custom field named "outgoing"

    
    
    <?php   
    //db parameters   
    $db_username = '';   
    $db_password = '';   
    $db_database = '';   
      
    $blog_url = 'http://www.com/blog/'; //base folder for the blog. Make SURE there is a slash at the end  
      
    //connect to the database   
    mysql_connect(localhost, $db_username, $db_password);   
    @mysql_select_db($db_database) or die("Unable to select database");   
      
    //get data from database -- !IMPORTANT, the "LIMIT 5" means how many posts will appear. Change the 5 to any whole number.   
    $query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY id DESC LIMIT 5";    
      
    $query_result = mysql_query($query);   
    $num_rows = mysql_numrows($query_result);   
      
    //close database connection   
    mysql_close();   
      
    // html page starts after   
    ?>   
    
    <?php  
      
    //start a loop that starts $i at 0, and make increase until it's at the number of rows   
    for($i=0; $i< $num_rows; $i++){    
      
    //assign data to variables, $i is the row number, which increases with each run of the loop   
    $blog_date = mysql_result($query_result, $i, "post_date");   
    $blog_title = mysql_result($query_result, $i, "post_title");   
    $blog_content = mysql_result($query_result, $i, "post_content");
    //$blog_permalink = mysql_result($query_result, $i, "guid"); //use this line for p=11 format.   
      
    $blog_permalink = $blog_url . mysql_result($query_result, $i, "post_name"); //combine blog url, with permalink title. Use this for title format   
      
    //format date   
    $blog_date = strtotime($blog_date);   
    $blog_date = strftime("%b %e", $blog_date);   
      
    //the following HTML content will be generated on the page as many times as the loop runs. In this case 5.   
    ?>
    
    
    <?php echo $blog_title; ?>
    <?php echo $blog_content; ?>
    <?php echo $blog_permalink; ?>
    <?php echo $blog_date; ?>
     
    I need to display the feature image thumbnail as well
    I need to display my post custom field with the name "outgoing"
    
    <?php   
    } //end the for loop   
    ?>
    
    
    Code (markup):
    Fix pays: $10.00 Payment after completion

    Im currently on gtalk and aim please send me a message with your info.


    For anyone who wants to claim the money. Just code it and message me the code .... and your paypal and after tested you will be rewarded.
     
    Last edited: Jun 24, 2011
    s2kinteg916, Jun 24, 2011 IP
  2. s2kinteg916

    s2kinteg916 Well-Known Member

    Messages:
    651
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Posted on Scriptlance and completed..........
     
    s2kinteg916, Jun 25, 2011 IP