function related_ads() {
$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_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;
}
add_action( 'appthemes_after_endwhile', 'related_ads' );
There are currently 1 users browsing this thread. (0 members and 1 guests)