Created
October 25, 2018 16:12
-
-
Save zkmark/a4b4538462c589c7a84ee879b7cae2e7 to your computer and use it in GitHub Desktop.
Last Post With Acf meta_query
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
@if ($tipo_de_post == 'ultimos_post_de_idioma') | |
<?php | |
$cantidad_de_post = get_sub_field('cantidad_de_post') + 10; | |
$ultimos_post_de_idiomas = get_sub_field('ultimos_post_de_idiomas'); | |
$id_of_series = []; | |
$list_of_series = get_posts([ | |
'post_type' => 'post', | |
'posts_per_page' => $cantidad_de_post, | |
]); | |
//var_dump($list_of_series); | |
if ( $list_of_series ) { | |
foreach ( $list_of_series as $list_of_serie ) { | |
//Si tiene Serie | |
$id_post_nombre_de_la_serie = get_field('post_nombre_de_la_serie', $list_of_serie->ID); | |
//echo 'ID: '. $list_of_serie->ID . ' $id_post_nombre_de_la_serie: '. $id_post_nombre_de_la_serie . '<BR>'; | |
if ($id_post_nombre_de_la_serie) { | |
//Si la Serie incluye el idioma | |
$id_serie_idioma_de_la_serie = get_field('serie_idioma_de_la_serie', $id_post_nombre_de_la_serie); | |
//echo 'ID: '. $list_of_serie->ID . ' $id_post_nombre_de_la_serie: '. $id_post_nombre_de_la_serie . '<BR>'; | |
if ($id_serie_idioma_de_la_serie == $ultimos_post_de_idiomas) { | |
//echo 'ID: '. $list_of_serie->ID . ' $id_post_nombre_de_la_serie: '. $id_post_nombre_de_la_serie . ' $id_serie_idioma_de_la_serie: ' . $id_serie_idioma_de_la_serie .'<BR>'; | |
array_push($id_of_series, $list_of_serie->ID); | |
} | |
} | |
} | |
} | |
//var_dump($id_of_series); | |
$args = Array( | |
'post_type' => 'post', | |
'post__in' => $id_of_series, | |
'posts_per_page' => get_sub_field('cantidad_de_post'), | |
); | |
?> | |
@elseif ($tipo_de_post == 'ultimas_series_de_idioma') | |
<?php | |
$idiomas_id = get_sub_field('ultimos_post_de_idiomas'); | |
$args = array( | |
'post_type' => 'serie', | |
'meta_query' => array( | |
array( | |
'key' => 'serie_idioma_de_la_serie', // name of custom field | |
'value' => $idiomas_id, // name of value ejample : english, spanish | |
'compare' => 'LIKE' | |
) | |
), | |
'posts_per_page' => get_sub_field('cantidad_de_post'), | |
); | |
//var_dump($the_query); | |
?> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment