Created
October 31, 2017 20:46
-
-
Save leobaiano/b4bb272c265bc53cad689737e759cec3 to your computer and use it in GitHub Desktop.
Alternando
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = [ | |
'post_type' => 'slider', | |
'posts_per_page' => 5, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'slider', | |
'field' => 'slug', | |
'terms' => array ('institutional-slider', 'image-slider') | |
) | |
) | |
]; | |
$slider = new WP_QUERY( $args ); | |
if ( $slider->have_posts() ) { | |
$institucional = []; | |
$image = []; | |
while ( $slider->have_posts() ) { | |
$slider->the_post(); | |
if ( has_term( 'institutional-slider', 'slider' ) ) { | |
$institucional[] = [ 'title' => get_the_title() ]; | |
} else if ( has_term( 'image-slider', 'slider' ) ){ | |
$image[] = [ 'title' => get_the_title() ]; | |
} | |
} | |
wp_reset_postdata(); | |
} | |
echo 'Posição 1 = ' . $institucional[0]['title']; | |
echo 'Posição 2 = ' . $image[0]['title']; | |
echo 'Posição 3 = ' . $institucional[1]['title']; | |
echo 'Posição 4 = ' . $image[1]['title']; | |
echo 'Posição 5 = ' . $institucional[2]['title']; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment