25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

265 satır
9.7 KiB

  1. <?php get_header() ?>
  2. <?php
  3. $site_host = parse_url(get_site_url(), PHP_URL_HOST);
  4. /**
  5. * Collect term data
  6. * =================
  7. */
  8. // custom term object with usefull data
  9. $term = sandbox_get_archive_term();
  10. // gets an array of all queried post types
  11. // instead of the post type of the first post with get_post_type()
  12. $post_type = $term->post_types;
  13. // archive related default values
  14. $related_taxonomies = array();
  15. $public_taxonomies = get_taxonomies(array('public' => true ));
  16. $post_ids = get_posts(array(
  17. 'post_type' => $post_type,
  18. 'posts_per_page' => -1,
  19. 'fields' => 'ids', // return an array of ids
  20. ));
  21. // Default more button text
  22. $more_text = __('Weiterlesen', 'sandbox');
  23. $more_text_label = ''; // used to use with printf
  24. $use_tax_more_text = false;
  25. // archive specificas based on archive type
  26. if ( is_tax() || is_tag() || is_category() ) {
  27. $related_taxonomies = array($term->taxonomy['WP_Taxonomy']->name);
  28. $meta_args = array('date', 'author');
  29. if ( $term->taxonomy['WP_Taxonomy']->name === 'typ' ) {
  30. $meta_args = array();
  31. }
  32. // More text button, %s gets replaced by
  33. // $more_text_label which will be $post_type_object->labels->singular_name
  34. // English default
  35. $more_text = __('View', 'sandbox') . ' %s';
  36. $use_tax_more_text = true;
  37. } else if ( is_post_type_archive() ) {
  38. $related_taxonomies = array_intersect(get_object_taxonomies($post_type), $public_taxonomies);
  39. // dont display post thumbnails in archives
  40. // manual overwrite, requested by client
  41. // $term->has_thumbnail = false;
  42. // echo '<!--', var_dump($taxonomies), '-->';
  43. // echo 'c: ', var_dump($related_taxonomies);
  44. }
  45. $header_style = '';
  46. if ( $term->has_thumbnail ) {
  47. if ( is_post_type_archive() ) {
  48. $term_thumbnail = array($term->thumbnail);
  49. } else {
  50. $term_thumbnail = wp_get_attachment_image_src($term->thumbnail_id, 'sandbox-hero');
  51. }
  52. $header_style = ' style="background-image:url(' . $term_thumbnail[0] . ');"';
  53. }
  54. ?>
  55. <section id="content" class="articles wrapper container<?php echo $term->classes; ?>">
  56. <header <?php post_class('section-header'); ?><?php echo $header_style; ?>>
  57. <h1 class="title"><?php echo $term->title; ?></h1>
  58. <?php if ( $term->has_description ) { ?>
  59. <div class="intro">
  60. <?php echo $term->description; ?>
  61. </div>
  62. <?php } ?>
  63. </header>
  64. <?php if ( ( is_home() || is_archive() ) && !is_front_page() ) { ?>
  65. <?php
  66. /*
  67. * @Sidebar Highlight
  68. */
  69. get_sidebar('highlight'); ?>
  70. <?php } ?>
  71. <?php
  72. /*
  73. * @Sidebar Content before
  74. */
  75. get_sidebar('content-before'); ?>
  76. <div class="inner">
  77. <?php if ( is_date() ) { rewind_posts(); } ?>
  78. <?php if ( have_posts() ) { ?>
  79. <?php /* <h2 class="title"><?php echo $term->byline ?></h2> */ ?>
  80. <?php while ( have_posts() ) : the_post() ?>
  81. <?php
  82. $post_id = get_the_ID();
  83. $post_type = get_post_type($post_id);
  84. $post_meta = sandbox_get_post_meta($post_id);
  85. if ( !isset($post_meta['_hide']) || !filter_var($post_meta['_hide'], FILTER_VALIDATE_BOOLEAN) ) {
  86. $post_taxonomies = sandbox_get_the_taxonomies_and_terms($post_id);
  87. $more_text = sandbox_get_more_text($post_type, $post_meta);
  88. $more_url = sandbox_get_more_url($post_type, $post_meta);
  89. $excerpt = '';
  90. $has_custom_more_url = $more_url !== get_permalink();
  91. $more_class = 'more';
  92. $more_target = '';
  93. $post_class = 'no-download';
  94. $content_meta_args = array('rtime', 'author', 'date');
  95. $subheadline = isset($post_meta['_subheadline']) ? apply_filters('the_content', $post_meta['_subheadline']) : '';
  96. // post thumbnail as background image
  97. $post_style = '';
  98. if ( has_post_thumbnail() ) {
  99. $post_style = ' style="background-image:url(' . get_the_post_thumbnail_url($post_id, 'sandbox-default') . ');"';
  100. }
  101. if ( $has_custom_more_url ) {
  102. if ( parse_url($more_url, PHP_URL_HOST) !== $site_host ) {
  103. $more_target = ' target="_blank" rel="noopener"';
  104. $more_class .= ' external';
  105. }
  106. if ( $post_type === 'link' ) {
  107. $more_text = __('go to website', 'sandbox');
  108. }
  109. }
  110. if ( !empty($description) ) {
  111. $excerpt = $description;
  112. }
  113. // Post type "page"
  114. if ( $post_type === 'page' ) {
  115. $content_meta_args = false;
  116. }
  117. // Post type "service"
  118. if ( $post_type === 'service' ) {
  119. $content_meta_args = false;
  120. }
  121. // Post type "aktivitaet"
  122. if ( $post_type === 'aktivitaet' ) {
  123. $content_meta_args = array('period');
  124. }
  125. // Post type "news"
  126. if ( $post_type === 'news' ) {
  127. $content_meta_args = false;
  128. }
  129. // Post type "product" fields
  130. $produkt_pdf = isset($post_meta['_pdf-download']) ? $post_meta['_pdf-download'] : '';
  131. $produkt_url = isset($post_meta['_product-url']) ? $post_meta['_product-url'] : '';
  132. if ( !empty($produkt_pdf) ) {
  133. $produkt_url = wp_get_attachment_url($produkt_pdf);
  134. }
  135. if ( $post_type === 'produkt' ) {
  136. $content_meta_args = false;
  137. $more_text = __('Details', 'sandbox');
  138. }
  139. // Download button
  140. $download_url = !empty($produkt_pdf) ? $produkt_pdf : '';
  141. $download_target = '';
  142. if ( !empty($download_url) ) {
  143. if ( parse_url($download_url, PHP_URL_HOST) !== $site_host ) {
  144. $download_target = ' target="_blank" rel="noopener"';
  145. }
  146. $post_class = 'has-download';
  147. }
  148. if ( empty($excerpt) ) {
  149. $excerpt = has_excerpt() ? get_the_excerpt() : wp_trim_words(get_the_content(), 40);
  150. }
  151. $excerpt .= ' <a class="more" href="' . get_the_permalink() . '">' . $more_text . '</a>';
  152. // more class attribute
  153. if ( $more_class !== '' ) {
  154. $more_class = ' class="' . $more_class . '"';
  155. }
  156. ?>
  157. <?php if ( is_tag('hoeren-sehen') ) { ?>
  158. <?php } else { ?>
  159. <?php } ?>
  160. <article id="post-<?php the_ID() ?>" <?php post_class($post_class) ?>>
  161. <div class="inner">
  162. <?php if ( has_post_thumbnail() ) { ?>
  163. <a href="<?php the_permalink() ?>" class="post-thumbnail"<?php echo $post_style; ?>><?php the_post_thumbnail('sandbox-default'); ?></a>
  164. <?php } ?>
  165. <div class="content">
  166. <?php if ( !empty($subheadline) ) { ?>
  167. <div class="subheadline">
  168. <?php echo $subheadline; ?>
  169. </div>
  170. <?php } ?>
  171. <h2 class="title"><a href="<?php echo $more_url; ?>"<?php echo $more_target; ?>><?php the_title() ?></a></h2>
  172. <?php if ( $meta = sandbox_get_meta_data($content_meta_args) ) { ?>
  173. <ul class="meta">
  174. <?php echo $meta; ?>
  175. </ul>
  176. <?php } ?>
  177. <?php echo apply_filters('the_content', $excerpt); ?>
  178. <?php /* if ( !empty($post_taxonomies) ) { ?>
  179. <dl class="clearfix">
  180. <?php foreach ( $post_taxonomies as $post_taxonomy ) { ?>
  181. <?php if ( !empty($post_taxonomy) && $post_taxonomy['slug'] !== 'lern_stufe' ) { ?>
  182. <dt class="<?php echo $post_taxonomy['slug']; ?>"><?php echo $post_taxonomy['label']; ?></dt>
  183. <?php foreach ( $post_taxonomy['terms'] as $post_taxonomy_term ) { ?>
  184. <dd class="<?php echo $post_taxonomy_term['slug']; ?>"><?php echo $post_taxonomy_term['label']; ?></dd>
  185. <?php } ?>
  186. <?php } ?>
  187. <?php } ?>
  188. </dl>
  189. <?php } */ ?>
  190. </div>
  191. </div>
  192. </article><!-- .post -->
  193. <?php } ?>
  194. <?php endwhile; ?>
  195. <?php } else { ?>
  196. <article id="post-0" class="post no-results not-found">
  197. <div class="inner">
  198. <div class="content">
  199. <h2 class="title"><?php printf(__( 'Not Found', 'sandbox' )); ?> :-(</h2>
  200. <p><?php
  201. if ( is_tag() ) {
  202. printf(__('No posts written tagged with', 'sandbox') . ' ' . single_tag_title(false));
  203. } elseif ( is_category() ) {
  204. printf(__('No posts written in', 'sandbox') . ' ' . single_cat_title(false));
  205. } elseif ( is_author() ) {
  206. printf(get_the_author() . ' ' . __("didn't wrote a post yet.", 'sandbox')); // 'hat noch keine Artikel verfasst.'
  207. } else {
  208. printf(__('Apologies, but we were unable to find what you were looking for. Perhaps searching will help.', 'sandbox'));
  209. }
  210. ?></p>
  211. <a href="<?php echo esc_url( home_url() ); ?>"><?php printf(__('Go to the homepage', 'sandbox')); // 'zur Startseite gehen' ?></a></p>
  212. </div>
  213. <form id="searchform-no-results" class="blog-search" method="get" action="<?php echo esc_url( home_url() ); ?>">
  214. <input id="s-no-results" name="s" class="text" type="text" value="<?php the_search_query() ?>" size="40" />
  215. <input class="button" type="submit" value="<?php printf(__('Find', 'sandbox')); ?>" />
  216. </form>
  217. </div>
  218. </article><!-- .post -->
  219. <?php } ?>
  220. </div>
  221. <?php
  222. /*
  223. * @Sidebar Content after
  224. */
  225. get_sidebar('content-after'); ?>
  226. <?php if ( sandbox_archive_is_paged($term) ) { ?>
  227. <?php if ( function_exists('wp_pagenavi') ) {
  228. wp_pagenavi(); // http://wordpress.org/plugins/wp-pagenavi/
  229. } else {
  230. ?>
  231. <nav id="nav-below" class="navigation">
  232. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&laquo;</span> Older results', 'sandbox' ) ) ?></div>
  233. <div class="nav-next"><?php previous_posts_link( __( 'Newer results <span class="meta-nav">&raquo;</span>', 'sandbox' ) ) ?></div>
  234. </nav>
  235. <?php } ?>
  236. <?php } ?>
  237. </section>
  238. <?php get_footer() ?>