ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) { $category_ids[] = $individual_category->term_id; } $args = array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=> $num, ); $the_query = new WP_Query($args); if( $the_query->have_posts() ): $posts = '' . $smof_data['afc_related_title'] . ''; while ($the_query->have_posts()): $the_query->the_post(); $posts .= ''; if ($smof_data['afc_display_img'] == 1) { $posts .= ''; if ( has_post_thumbnail() ) { $posts .= get_the_post_thumbnail( $post->ID, 'fab-200' ); } $posts .= ''; } $posts .= '' . get_the_title() . ' '; endwhile; $posts .= ''; endif; wp_reset_query(); return $posts; }//end if }//end if //related content by tags if($smof_data['afc_related_type'] == 'tag' && is_single()){ $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $tags[0]->term_id; $args = array( 'tag__in' => $first_tag, 'post__not_in' => array($post->ID), 'posts_per_page'=>$num, ); $the_query = new WP_Query($args); if( $the_query->have_posts() ): $posts = '' . $smof_data['afc_related_title'] . ''; while ($the_query->have_posts()): $the_query->the_post(); $posts .= ''; if ($smof_data['afc_display_img'] == 1) { $posts .= ''; if ( has_post_thumbnail() ) { $posts .= get_the_post_thumbnail( $post->ID, 'fab-200' ); } $posts .= ''; } $posts .= '' . get_the_title() . ' '; endwhile; $posts .= ''; return $posts; endif; wp_reset_query(); }//end if } }