accueil.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * template name: Accueil
  4. */
  5. use Timber\Post;
  6. use Timber\Timber;
  7. $context = Timber::get_context();
  8. $post = new Post();
  9. $context['post'] = $post;
  10. $projet = array(
  11. 'post_type' => 'les-projets',
  12. 'post_status'=>'publish',
  13. 'numberposts' => 3
  14. );
  15. $tpsF = array(
  16. 'post_type' => 'les-temps-forts',
  17. 'post_status'=>'publish',
  18. 'numberposts' => 3
  19. );
  20. $today = date('Y-m-d H:i:s');
  21. $args = array (
  22. 'post_type' => 'post',
  23. 'orderby' => 'informations_debut_event',
  24. 'order' => 'ASC',
  25. 'meta_query' => array(
  26. array(
  27. 'key' => 'informations_debut_event',
  28. 'compare' => '>=',
  29. 'value' => $today,
  30. ),
  31. ),
  32. 'numberposts' => 3
  33. );
  34. $context['video_url'] = get_field('video_la_mine', FALSE, FALSE);
  35. $context['projet'] = Timber::get_posts( $projet );
  36. $context['posts'] = Timber::get_posts( $args );
  37. $count_events = count($context['posts']);
  38. $args = array (
  39. 'post_type' => 'post',
  40. 'orderby' => 'informations_fin_event',
  41. 'order' => 'ASC',
  42. 'meta_query' => array(
  43. array(
  44. 'key' => 'informations_fin_event',
  45. 'compare' => '>=',
  46. 'value' => $today,
  47. ),
  48. ),
  49. 'numberposts' => 3
  50. );
  51. if ($count_events == 0) {
  52. $context['posts_now'] = Timber::get_posts( $args );
  53. }
  54. $context['tpsF'] = Timber::get_posts( $tpsF );
  55. Timber::render('accueil.twig', $context);