LeoLopesWeb
6/15/2018 - 7:08 PM

shortcode com custom post type e taxonomy

function lista_paginas($atts) {
  ob_start();
  $a = shortcode_atts( array(
    'categoria' => '',
  ), $atts );    
	echo'<div class="">';  

			global $post;          
			$args = array(
					'post_type'      => 'page',
					'posts_per_page' => -1,
					'post_parent'    => $post->ID,
					'order'          => 'DESC',
					'orderby'        => 'meta_value',
					'ignore_sticky_posts' => true,
					'post__not_in' => array( $post->ID )
			); 
      $query = new WP_Query( $args );  
      if ( $query->have_posts() ) :   
        while ( $query->have_posts() ) : $query->the_post();
					echo '<div class="item">';
					echo '<a href="'.get_the_permalink().'">';
          echo '<p><img src="'.wp_get_attachment_url( get_post_thumbnail_id() ).'"></p>';
          echo '<h3>'.get_the_title().'</h3>';
					//echo '<p>'.get_the_content().'</p>';
					echo '</a>';
          echo '</div>';
        endwhile;   
      endif; 
			wp_reset_postdata();  
			
    echo'</div>'; 
  $content = ob_get_contents();
  ob_end_clean();
  return $content;
}
add_shortcode('lista-paginas', 'lista_paginas');