Guest User

Untitled

a guest
Jul 12th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. <?php
  2. $date = get_the_date("Y-m-d");
  3.  
  4. $d = explode("-", $date);
  5. $cats = get_the_category();
  6. $version = "";
  7. foreach($cats as $kat) {
  8. //print_r($kat);
  9. if ($kat->slug=="damals-aktuelles-heft") {
  10. $version = "damals-aktuelles-heft";
  11. $search = "titelbeitrag";
  12.  
  13. }
  14. if ($kat->slug=="weitere-themen") {
  15. $version = "weitere-themen";
  16. $search = "damals-aktuelles-heft";
  17.  
  18. }
  19. }
  20.  
  21. $args = array(
  22. 'id' => false,
  23. 'post_type' => 'post',
  24. 'order' => 'DESC',
  25. 'orderby' => 'date',
  26. 'post_status' => 'publish',
  27. 'category_name' => $search,
  28. 'date_query' => array(
  29. 'year' => intval($d[0]),
  30. 'month' => intval($d[1]),
  31. 'day' => intval($d[2])
  32. )
  33.  
  34. );
  35.  
  36. switch ($version) {
  37. case 'damals-aktuelles-heft':
  38.  
  39. $args["posts_per_page"] = -1;
  40. global $posts;
  41. $original_posts = $posts;
  42. $titelids = array();
  43. $posts = new WP_Query( $args );
  44. ob_start();
  45. echo "<h3>Beiträge in dieser Ausgabe</h3>";
  46. if ( $posts->have_posts() ) {
  47. while ( $posts->have_posts() ) :
  48. $posts->the_post();
  49. global $post;
  50. $more_link = '<a class="herald-science-read-more" href="' . esc_url( get_permalink() ) .'" title="' . esc_attr( get_the_title() ) . '">' . __herald('read_more') . '</a>';
  51. $titelids[] = get_the_id();
  52. ?>
  53. <div class="row">
  54. <?php
  55. $cw = 12;
  56. if ( has_post_thumbnail() ) : ?>
  57. <div class="col-lg-4 col-md-4 col-sm-4">
  58. <div class="herald-post-thumbnail herald-format-icon-middle">
  59. <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>">
  60. <?php
  61. $fimg = herald_get_featured_image( 'herald-lay-b1' );
  62. echo $fimg; ?>
  63. <?php echo herald_post_format_icon(); ?>
  64. </a>
  65. </div>
  66. </div>
  67. <?php
  68. $cw=8;
  69. endif; ?>
  70.  
  71. <div class="col-lg-<?php echo $cw; ?> col-md-<?php echo $cw; ?> col-sm-<?php echo $cw; ?>">
  72. <div class="entry-header">
  73. <span class="meta-category"><?php echo herald_get_category(); ?></span>
  74. <?php the_title( sprintf( '<h2 class="entry-title h2"><a href="%s">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
  75. </div>
  76. <div class="entry-content"><?php echo herald_get_excerpt( 'a' , $more_link); ?></div>
  77. </div>
  78. </div>
  79. <?php
  80.  
  81. endwhile;
  82. }
  83. ?>
  84. <hr/>
  85. <?php
  86. $args["category_name"] = "weitere-themen";
  87. $posts = new WP_Query( $args );
  88.  
  89. if ( $posts->have_posts() ) {
  90. while ( $posts->have_posts() ) :
  91. $posts->the_post();
  92. global $post;
  93. if (!in_array(get_the_id(), $titelids)) {
  94. $more_link = '<a class="herald-science-read-more" href="' . esc_url( get_permalink() ) .'" title="' . esc_attr( get_the_title() ) . '">' . __herald('read_more') . '</a>';
  95. ?>
  96. <div class="row">
  97. <?php
  98. $cw = 12;
  99. if ( has_post_thumbnail() ) : ?>
  100. <div class="col-lg-4 col-md-4 col-sm-4">
  101. <div class="herald-post-thumbnail herald-format-icon-middle">
  102. <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>">
  103. <?php
  104. $fimg = herald_get_featured_image( 'herald-lay-b1' );
  105. echo $fimg; ?>
  106. <?php echo herald_post_format_icon(); ?>
  107. </a>
  108. </div>
  109. </div>
  110. <?php
  111. $cw=8;
  112. endif; ?>
  113.  
  114. <div class="col-lg-<?php echo $cw; ?> col-md-<?php echo $cw; ?> col-sm-<?php echo $cw; ?>">
  115. <div class="entry-header">
  116. <span class="meta-category"><?php echo herald_get_category(); ?></span>
  117. <?php the_title( sprintf( '<h2 class="entry-title h2"><a href="%s">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
  118. </div>
  119. <div class="entry-content"><?php echo herald_get_excerpt( 'a' , $more_link); ?></div>
  120. </div>
  121. </div>
  122. <?php
  123. }
  124. endwhile;
  125. }
  126.  
  127.  
  128.  
  129. $output = ob_get_contents();
  130. ob_end_clean();
  131. $posts = $original_posts;
  132.  
  133. wp_reset_postdata();
  134. wp_reset_query();
  135. break;
  136. case 'weitere-themen':
  137. $args["posts_per_page"] = 1;
  138. global $posts;
  139. $original_posts = $posts;
  140. $posts = new WP_Query( $args );
  141. ob_start();
  142. if ( $posts->have_posts() ) {
  143. while ( $posts->have_posts() ) :
  144. $posts->the_post();
  145. global $post;
  146. ?>
  147. <?php the_title( sprintf( '<p class=""><a href="%s">Zur Übersicht: ', esc_url( get_permalink() ) ), '</a></p>' ); ?>
  148. <?php
  149. endwhile;
  150. }
  151.  
  152. break;
  153. default:
  154. echo "";
  155. break;
  156. }
  157. ?>
  158. <?php
  159. echo $output;
  160.  
  161. ?>
Add Comment
Please, Sign In to add comment