single.php 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * The Template for displaying all single posts
  4. *
  5. * Methods for TimberHelper can be found in the /lib sub-directory
  6. *
  7. * @package WordPress
  8. * @subpackage Timber
  9. * @since Timber 0.1
  10. */
  11. $context = Timber::context();
  12. $timber_post = Timber::query_post();
  13. $context['post'] = $timber_post;
  14. $categories = get_the_terms( $id, 'category' );
  15. foreach ( $categories as $category ) {
  16. $cat = $category->slug;
  17. }
  18. $current_id[] = get_the_ID();
  19. $args = get_posts(array(
  20. 'post_type' => 'post',
  21. 'post_status' => 'publish',
  22. 'orderby' => 'meta_value',
  23. 'meta_key' => 'informations_debut_event',
  24. 'order' => 'ASC',
  25. 'posts_per_page' => 6,
  26. 'category_name' => $cat,
  27. 'post__not_in' => $current_id,
  28. 'meta_query' => array(
  29. array(
  30. 'meta_key' => 'informations_end_event',
  31. 'value' => date('Y-m-d H:i:s'),
  32. 'compare' => '>=',
  33. 'type' => 'DATE',
  34. ),
  35. ),
  36. ));
  37. $context['other'] = $args;
  38. Timber::render('single.twig', $context );