You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

249 lines
9.3 KiB

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