Skip to content

Instantly share code, notes, and snippets.

@jassriver
Created June 6, 2023 19:33
Show Gist options
  • Save jassriver/ee8b1fb1eae3a9c8144fce6912188dff to your computer and use it in GitHub Desktop.
Save jassriver/ee8b1fb1eae3a9c8144fce6912188dff to your computer and use it in GitHub Desktop.
pegar_filmes_de_2_anos_atras_ate_agora
<?php
$ano_atual = date('Y');
$dois_anos_atras = $ano_atual - 2;
$args = array(
'post_type' => 'filmes',
'meta_query' => [
'relation' => 'AND',
[
'key' => 'genero',
'value' => 'ação',
'type' => 'CHAR'
],
[
'key' => 'genero',
'value' => 'suspense',
'type' => 'CHAR'
],
[
'relation' => 'AND',
[
'key' => 'ano_lancamento',
'value' => $dois_anos_atras,
'type' => 'NUMERIC',
'compare' => '>='
],
[
'key' => 'ano_lancamento',
'value' => $ano_atual,
'type' => 'NUMERIC',
'compare' => '<='
]
]
]
);
$query = New WP_Query($args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment