Anyone can modified this code to show the related ads on single-ad-listing.php..Please help me out for this code..
<?php
$term = wp_get_object_terms($post->ID, APP_TAX_CAT);
$parent = $term[0]->parent;
$parents[] = $term[0]->term_id;
$sql = "SELECT term_id, slug FROM `wp_ub_terms` WHERE term_id = $parent";
$resultat = mysql_query($sql);
while($post=mysql_fetch_array($resultat)) {
$newslug = $post['slug'];
}
$thePostID = $wp_query->post->ID;
$args = array( 'numberposts' => 3, 'orderby' => 'rand', 'post_type' => APP_POST_TYPE, APP_TAX_CAT => $newslug, 'exclude' => $thePostID);
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><?php cp_ad_featured_thumbnail(); ?><a id="related-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>