viniciusnw
7/13/2016 - 4:48 PM

Loop para pegar posts types com meta query

Loop para pegar posts types com meta query

#Dentro do loop dos posts

# Pegar url da thumbnail
wp_get_attachment_url( get_post_thumbnail_id() );

# Pegar a url das variacoes de thumbnail
wp_get_attachment_image_src( get_post_thumbnail_id(), 'tamanho' );

# Pegar Thumbnail/variacoes
the_post_thumbnail( 'thumb-square', array('class' => 'img-circle') );

# Get post meta
get_post_meta( get_the_id(), 'ID_META_BOX', true )

# Text area formatado
echo wpautop();

# Get option theme
foundation_q_get_option( )
// Query posts
$posts_data = get_posts(array(
  'post_type'      => 'POST_TYPE',
  'post__in'       => array(id, id),
  'posts_per_page' => 'number',
  'order'          => 'ASC',
  'meta_query'     => array(
    array(
      'key' => 'ID_DO_POST_TYPE+ID_DO_CUSTOM_FIELD',
      'value' => 'on'
    )
  )
));

// Query posts tax/terms
$posts_data = get_posts(array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy' => $taxonomy,
            'field' => 'slug',
            'terms' => $term->slug,
        ),
    ),
));

<?php 
  if( $posts_data ): 
    foreach( $posts_data as $post ): setup_postdata( $post ); ?>

<?php 
    endforeach; 
  endif; ?>