Display the_tags in Wordpress for Custom Query

Discussion in 'PHP' started by ridesign, Jun 13, 2009.

  1. #1
    I currently have a custom select query but I can not access the tags using the_tags

    $hdqry = "SELECT wp_posts.* FROM wp_posts WHERE wp_posts.post_password = '' AND wp_posts.post_status = 'publish' AND wp_posts.post_type = 'post' AND wp_posts.ID > 10000 ORDER BY wp_posts.post_date DESC LIMIT 5";
    		//$hdqry = "SELECT wp_posts.ID, wp_posts.post_title FROM wp_posts WHERE wp_posts.post_password = '' AND wp_posts.post_status = 'publish' AND wp_posts.post_type = 'post' ORDER BY wp_posts.post_date DESC LIMIT 5";
    $myhd = $wpdb->get_results($hdqry);
      foreach($myhd as $hd) : setup_postdata($myhd);
    
    global $wp_query;
    $wp_query->in_the_loop = true;
     $title = $hd->post_title;
        
          ?>
    	  
    	 
     
     <a href="<?php echo $hd->guid; ?>" rel="bookmark" title="Permanent Link to <?php echo $title; ?>"><?php echo $title; ?></a>
      <?php echo $hd->post_content; ?>
    <?php if ( function_exists('the_tags') ) { the_tags('Tags: ', ', ', ''); } else { echo "Error:"; } ?>
    
    <?php endforeach; ?>
    PHP:

     
    ridesign, Jun 13, 2009 IP