• # August 13, 2014 at 1:04 am


    I’ve been Googling around but can’t seem to find a snippet for my problem.
    I have two custom post types – Foods, Promos. Now I have a section on my homepage where I want to show 3 ‘featured’ items either from the Promos or Foods with a tag of ‘featured’.

    So basically I just want a snippet to show 3 posts with a tag = ‘featured’ from those two custom post type. I am able to show post with a tag of ‘featured’ but only from Foods or only from Promos.


    # August 13, 2014 at 2:58 am

    Ok, I’ve managed to do it but really not sure if it’s even the best way to do it.

    <ul class=”featured-list”>
    $type = array(‘promo’, ‘food’);
    $args = array(
    ‘tag’ => ‘featured’,
    ‘post_type’ => $type,
    ‘post_status’ => ‘publish’,
    ‘numberposts’ => 3

          $my_query = null;
          $my_query = new WP_Query($args);
          if($my_query-&gt;have_posts()) {
            while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
              &lt;div class="promo-thumb"&gt;
                  if ( has_post_thumbnail() ) {
                  } else { ?&gt;
                    &lt;img src="&lt;?php echo get_template_directory_uri(); ?&gt;/images/default-featured-thumb.png" alt=""&gt;
                  &lt;?php } ?&gt;
              &lt;h3 class="promo-name"&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
              &lt;div class="promo-desc"&gt;&lt;?php the_content(); ?&gt;&lt;/div&gt;
              &lt;a href="#" class="button"&gt;Read more&lt;/a&gt;


    # August 16, 2014 at 2:59 pm

    Did you check Here?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.