Created
February 21, 2019 23:43
-
-
Save rodrigophpweb/c62e475a87fb6a7a8e4e60d330cf3f3f to your computer and use it in GitHub Desktop.
Search date + name
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 if ($_GET['de'] || $_GET['ate'] || $_GET['s']) : ?> | |
<?php | |
$start = date_parse_from_format("j.n.Y", $_GET['de']); | |
$end = date_parse_from_format("j.n.Y", $_GET['ate']); | |
$args = array( | |
'post_type' => array('publicacao', 'apresentacoes', 'informe'), | |
'orderby' => 'date', | |
'order' => 'ASC', | |
'posts_per_page' => 10, | |
//'s' => $_GET['nome'], | |
'date_query' => array( | |
'relation' => 'AND', | |
array( | |
'after' => array( | |
'year' => $start['year'], | |
'month'=> $start['month'], | |
'day' => $start['day'], | |
), | |
'inclusive' => true, | |
), | |
array( | |
'before' => array( | |
'year' => $end['year'], | |
'month'=> $end['month'], | |
'day' => $end['day'], | |
), | |
'inclusive' => true, | |
), | |
), | |
); | |
$the_query = new WP_Query( $args ); | |
var_dump($args); | |
?> | |
<?php if ( $the_query->have_posts() ) : ?> | |
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
<tr> | |
<td> | |
<?php the_title();?></td> | |
<td> | |
<?php | |
$post_type = get_post_type( get_the_ID() ); | |
if ($post_type == 'apresentacoes'){ | |
echo 'Apresentações'; | |
}elseif($post_type == 'publicacao'){ | |
echo 'Publicações'; | |
}elseif($post_type == 'informe'){ | |
echo 'Informe'; | |
} | |
?> | |
</td> | |
<td><?php the_time('d/m/Y')?></td> | |
<td><a href="<?php the_field('arquivo');?>" class="btndown">Download</a></td> | |
</tr> | |
<?php endwhile; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php else : ?> | |
<?php | |
echo ' | |
<tr> | |
<td colspan="4">Não existe posts nesses momento</td> | |
</tr> | |
'; | |
?> | |
<?php endif; ?> | |
<?php else :?> | |
<?php | |
$args = array( | |
'post_type' => array('publicacao', 'apresentacoes', 'informe'), | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'posts_per_page' => 10, | |
); | |
$the_query = new WP_Query( $args ); | |
?> | |
<?php if ( $the_query->have_posts() ) : ?> | |
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
<tr> | |
<td> | |
<?php the_title();?></td> | |
<td> | |
<?php | |
$post_type = get_post_type( get_the_ID() ); | |
if ($post_type == 'apresentacoes'){ | |
echo 'Apresentações'; | |
}elseif($post_type == 'publicacao'){ | |
echo 'Publicações'; | |
}elseif($post_type == 'informe'){ | |
echo 'Informe'; | |
} | |
?> | |
</td> | |
<td><?php the_time('d/m/Y')?></td> | |
<td><a href="<?php the_field('arquivo');?>" class="btndown">Download</a></td> | |
</tr> | |
<?php endwhile; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php else : ?> | |
<?php | |
echo ' | |
<tr> | |
<td colspan="4">Não existe posts nesses momento</td> | |
</tr> | |
'; | |
?> | |
<?php endif; ?> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment