Advertisement
Guest User

NAB - Index.php | Likobu

a guest
Nov 5th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. <?php
  2. get_header();
  3.  
  4. ?>
  5.  
  6. <?php
  7.  
  8. // global $wp_query;
  9.  
  10. // 1) invoquer notre Objet WP_Query qui nou sera utile tout au long de cette page
  11. $wp_query_object = new WP_Query();
  12.  
  13.  
  14. /* 4 Premiers Posts
  15. *******************/
  16.  
  17. // 2) Créer un tableau de critères de recherche pour retrouver les postes qu'on veux
  18. $criteres_de_recherche = array(
  19.  
  20. 'category__not_in' => array( 7 ),
  21. 'posts_per_page' => 4
  22.  
  23. );
  24.  
  25. $quatre_premiers_posts = $wp_query_object->query( $criteres_de_recherche );
  26.  
  27. //echo $quatre_premiers_posts[0]->post_title;
  28. //print_r( $quatre_premiers_posts );
  29.  
  30. /* générer les tags des posts
  31. *******************************/
  32.  
  33. $t0 = wp_get_post_tags($quatre_premiers_posts[0]->ID);
  34. $t1 = wp_get_post_tags($quatre_premiers_posts[1]->ID);
  35. $t2 = wp_get_post_tags($quatre_premiers_posts[2]->ID);
  36. $t3 = wp_get_post_tags($quatre_premiers_posts[3]->ID);
  37. // print_r($t0);
  38. // print_r($t1);
  39. // print_r($t2);
  40. // print_r($t3);
  41.  
  42.  
  43. /* générer les permaliens
  44. *************************************************/
  45.  
  46. $perma0 = get_permalink($quatre_premiers_posts[0]->ID);
  47. $perma1 = get_permalink($quatre_premiers_posts[1]->ID);
  48. $perma2 = get_permalink($quatre_premiers_posts[2]->ID);
  49. $perma3 = get_permalink($quatre_premiers_posts[3]->ID);
  50. // print_r($perma0);
  51. // print_r($perma1);
  52. // print_r($perma2);
  53. // print_r($perma3);
  54.  
  55.  
  56. /* Générer les posts de news (DANS LA PRESSE)
  57. *************************************************/
  58.  
  59. $criteres_de_recherche = array (
  60.  
  61. 'category__in' => array (7),
  62. 'posts_per_page' => 2
  63.  
  64. );
  65.  
  66. $agenda_posts = $wp_query_object->query($criteres_de_recherche);
  67. // print_r ($agenda_posts);
  68.  
  69.  
  70. /* Générer les liens (Custom Field) des articles de l'agenda
  71. ************************************************************/
  72.  
  73. $champslien = get_post_custom($agenda_posts[0]->ID);
  74. $lien = $champslien['lien'];
  75.  
  76. $champslien2 = get_post_custom($agenda_posts[1]->ID);
  77. $lien2 = $champslien2['lien'];
  78. // print_r($lien);
  79.  
  80.  
  81. /* générer les images thumbnail (articles)
  82. ***************************************************/
  83.  
  84.  
  85. $mon_image0 = wp_get_attachment_image_src( get_post_thumbnail_id($quatre_premiers_posts[0]->ID), 'original');
  86. $mon_image1 = wp_get_attachment_image_src( get_post_thumbnail_id($quatre_premiers_posts[1]->ID), 'original');
  87. $mon_image2 = wp_get_attachment_image_src( get_post_thumbnail_id($quatre_premiers_posts[2]->ID), 'original');
  88. $mon_image3 = wp_get_attachment_image_src( get_post_thumbnail_id($quatre_premiers_posts[3]->ID), 'original');
  89. //print_r( $mon_image0 );
  90.  
  91.  
  92.  
  93.  
  94. ?>
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. <!-- Ouverture et début du main. -->
  105.  
  106. <div id="main">
  107.  
  108. <!-- Première colonne, première ligne - article 1 et son thumbnail, le tout sur deux colonnes. -->
  109.  
  110. <div class="left mr mt col gudea">
  111.  
  112. <div class="post-date left"><?php echo mysql2date("j F Y", $quatre_premiers_posts[0]->post_date);?> | <?php echo $t0[0]->name; ?> | <?php echo $t0[1]->name; ?>
  113. </div>
  114. <div class="clear">
  115. </div>
  116. <h1><a href="<?php echo $perma0 ?>"><?php echo $quatre_premiers_posts[0]->post_title;?>
  117. </a></h1>
  118. <div class="extrait"> <?php echo cut($quatre_premiers_posts[0]->post_excerpt, 600) ?>
  119. <div class="suite"><?php echo lire_la_suite($perma0) ?></div>
  120. </div>
  121. </div>
  122.  
  123.  
  124.  
  125. <div class="left mr2 mt colimage ">
  126. <div class="post-thumbnail"><a href="<?php echo $perma0 ?>"><img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php echo $mon_image0[0]; ?>&w=272&h=400" alt=" L'image à la une de cet article!"></a>
  127. </div>
  128. </div>
  129.  
  130.  
  131. <!-- Fin du premier article et de son image sur deux colonnes. -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement