Guest User

Untitled

a guest
Nov 9th, 2019
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /* Template Name: Acceuil */
  3. if ( ! defined( 'ABSPATH' ) ) { exit; }
  4. // Header
  5. get_header();
  6. $args = array(
  7. 'post_type' => array('post'),
  8. 'nopaging' => false,
  9. 'posts_per_page' => '3',
  10. 'orderby' => 'date',
  11. );
  12. $query = new WP_Query( $args );
  13. ?>
  14. <!--section 1 -->
  15. <div class="container">
  16. <h2 class="text-center">Nos films</h2>
  17. <div class="row">
  18. <?php
  19. if ($query->have_posts()) :
  20. while ($query->have_posts()) : $query->the_post();
  21. $titre = get_field('titre');
  22. $texte = get_field('texte');
  23. $note = get_field('note');
  24. $image = get_field('image');
  25. $date = get_field('date');
  26. $badge_if = get_field('afficher');
  27. ?>
  28. <div class="col-md-4">
  29. <div class="card">
  30. <img class="card-img-top" src="<?= esc_url($image['url']); ?>" alt="<?= esc_attr($image['alt']); ?>" />
  31. <div class="card-body">
  32. <?php
  33. if( $badge_if == 1): ?>
  34. <span class="badge badge-secondary">New</span>
  35. <?php endif; ?>
  36.  
  37. <?php if ($note): ?>
  38. <div class="stars-block">
  39. <?php
  40. switch ($note) {
  41. case 0:
  42. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars.png" alt="icon stars">';
  43. break;
  44. case 1:
  45. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars1.png" alt="icon stars">';
  46. break;
  47. case 2:
  48. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars2.png" alt="icon stars">';
  49. break;
  50. case 3:
  51. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars3.png" alt="icon stars">';
  52. break;
  53. case 4:
  54. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars4.png" alt="icon stars">';
  55. break;
  56. case 5:
  57. echo '<img src="'.esc_url(get_template_directory_uri()).'/img/png/stars5.png" alt="icon stars">';
  58. break;
  59. }
  60. ?>
  61. </div>
  62. <?php endif; ?>
  63. <h5 class="card-title"><?= esc_html($titre); ?></h5>
  64. <p class="card-text"><?= esc_html($texte); ?></p>
  65. <?php if ($date): ?>
  66. <p class="card-text">Date de sortie: <br> <?= esc_html($date); ?></p>
  67. <?php endif; ?>
  68. <a href="<?php the_permalink() ?>" class="btn btn-primary">Go somewhere</a>
  69. </div>
  70. </div>
  71. </div>
  72. <?php endwhile; ?>
  73. <?php endif; ?>
  74. <?php wp_reset_postdata(); ?>
  75. </div><!-- /row-->
  76. </div><!-- /Container-->
  77.  
  78. <?php get_footer(); ?>
RAW Paste Data