Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

198 wiersze
7.6 KiB

  1. <?php
  2. /**
  3. * Template Name: Home
  4. *
  5. * Page template with wide content area and without the secondary sidebar .
  6. *
  7. */
  8. get_header() ?>
  9. <?php the_post() ?>
  10. <?php
  11. $post_id = get_the_ID();
  12. $post_type = get_post_type($post_id);
  13. $post_meta = sandbox_get_post_meta($post_id);
  14. $section_classes = array();
  15. $excerpt = '';
  16. $subheadline = isset($post_meta['_subheadline']) ? apply_filters('the_content', $post_meta['_subheadline']) : '';
  17. // post thumbnail as background image
  18. $post_style = '';
  19. if ( has_post_thumbnail() ) {
  20. $section_classes[] = 'has-thumbnail';
  21. $post_style = ' style="background-image:url(' . get_the_post_thumbnail_url($post_id, 'sandbox-hero') . ');"';
  22. }
  23. // Post type "page"
  24. if ( $post_type === 'page' ) {
  25. $content_meta_args = false;
  26. }
  27. if ( empty($excerpt) ) {
  28. $excerpt = apply_filters('the_content', has_excerpt() ? get_the_excerpt() : get_the_content());
  29. }
  30. ?>
  31. <section id="content" class="articles wrapper container <?php echo implode(' ', $section_classes); ?>">
  32. <header id="post-<?php the_ID(); ?>" <?php post_class('section-header'); ?><?php echo $post_style; ?>>
  33. <div class="inner">
  34. <h1 class="title"><?php the_title() ?></h1>
  35. <?php if ( !empty($subheadline) ) { ?>
  36. <div class="subheadline">
  37. <?php echo $subheadline; ?>
  38. </div>
  39. <?php } ?>
  40. <?php if ( !empty($excerpt) ) { ?>
  41. <div class="intro">
  42. <?php echo $excerpt; ?>
  43. </div>
  44. <?php } ?>
  45. </div>
  46. </header>
  47. <div class="inner">
  48. <?php
  49. /**
  50. * Custom teaser loop
  51. * ==================
  52. * Needs a post type "teaser"
  53. * Looks for featured images
  54. * ------------------------
  55. * Fill out your post query
  56. *
  57. */
  58. $startpagePagesOptions = array(
  59. 'post_type' => 'any',
  60. 'teaser' => 'in-3-schritten-zum-pool',
  61. 'posts_per_page' => 3,
  62. 'orderby' => 'menu_order',
  63. 'order' => 'ASC',
  64. );
  65. $customQuery = new WP_Query($startpagePagesOptions);
  66. // include(locate_template('loop-teaser-linked.php'));
  67. ?>
  68. </div>
  69. </section>
  70. <?php
  71. /**
  72. * Product post type / Type tax / Products
  73. * =======================================
  74. */
  75. $product_post_type_name = 'produkt';
  76. $product_post_type_object = get_post_type_object($product_post_type_name);
  77. ?>
  78. <?php if ( $product_post_type_object && $product_post_type_object->has_archive ) { ?>
  79. <?php
  80. $post_type_ID = esc_attr($product_post_type_name);
  81. $post_type_url = esc_url(get_post_type_archive_link($product_post_type_name));
  82. $post_type_labels = apply_filters('post_type_labels_' . $product_post_type_name, $product_post_type_object->labels);
  83. $post_type_label = apply_filters('the_title', $product_post_type_object->label);
  84. $moreText = 'View all ' . $post_type_labels->name;
  85. if ( $product_post_type_name === 'download_aktion_de' ) {
  86. $moreText = __('To', 'sandbox') . ' ' . $post_type_labels->name;
  87. }
  88. $post_type_description = apply_filters('the_content', apply_filters('get_the_post_type_description', $product_post_type_object->description, $product_post_type_object));
  89. $post_type_classes = array(
  90. $product_post_type_name,
  91. 'type-' . $product_post_type_name,
  92. 'status-publish',
  93. 'has-post-thumbnail',
  94. 'hentry',
  95. 'has-thumbnail',
  96. );
  97. $post_type_image = esc_url(get_template_directory_uri() . '/img/' . esc_attr($product_post_type_name) . '.jpg');
  98. $post_type_style = ' style="background-image:url('. esc_url(get_stylesheet_directory_uri()) . '/img/logo-windpool.svg), url(' . $post_type_image . ');"';
  99. /**
  100. * types - Produkttypen
  101. * ====================
  102. * mit Top 4 Artikel je Bereich sortiert nach Reihenfolge
  103. */
  104. $types_taxonomy = get_taxonomy('typ');
  105. $types_options = array(
  106. 'taxonomy' => $types_taxonomy->name,
  107. 'post_type' => $post_type,
  108. 'orderby' => 'term_order',
  109. 'order' => 'ASC',
  110. );
  111. $types = new WP_Term_Query($types_options);
  112. $types_terms = $types->get_terms();
  113. ?>
  114. <section id="<?php echo $post_type_ID; ?>" class="<?php echo esc_attr(implode(' ', $post_type_classes)); ?>">
  115. <header class="section-header"<?php echo $post_type_style; ?>>
  116. <div class="inner">
  117. <h2 class="title"><a href="<?php echo $post_type_url; ?>?mtb=h-l-<?php echo $post_type_ID; ?>"><?php echo $post_type_label; ?></a></h2>
  118. <?php if ( !empty($post_type_description) ) { ?>
  119. <div class="intro">
  120. <?php echo $post_type_description; ?>
  121. <?php if ( !empty( $types->terms ) ) { ?>
  122. <ul class="terms-list taxonomy-<?php echo $types_taxonomy->name; ?>">
  123. <?php foreach( $types_terms as $type ) { ?>
  124. <?php
  125. $type_url = esc_url(get_term_link($type));
  126. $type_classes = array(
  127. 'more',
  128. $type->taxonomy,
  129. $type->taxonomy . '-' . $type->slug,
  130. $type->slug
  131. );
  132. $type_meta = get_term_meta($type->term_id);
  133. $type_image_id = isset($type_meta['_term_image']) && !empty($type_meta['_term_image'][0]) ? intval($type_meta['_term_image'][0]) : 0;
  134. // post thumbnail as background image
  135. $type_style = '';
  136. if ( $type_image_id !== 0 ) {
  137. $type_classes[] = 'has-post-thumbnail';
  138. $type_image_src = wp_get_attachment_image_src($type_image_id, 'sandbox-default');
  139. $type_style = ' style="background-image:url(' . $type_image_src[0] . ');"';
  140. }
  141. $type_description = isset($type_meta['_term_short_description']) && !empty($type_meta['_term_short_description'][0]) ? $type_meta['_term_short_description'][0] : wp_trim_words($type->description, 40);
  142. ?>
  143. <li class="<?php echo implode(' ', $type_classes); ?>"><a href="<?php echo $type_url; ?>" rel="bookmark"><?php echo apply_filters('the_title', $type->name); ?></a></li>
  144. <?php } ?>
  145. <li class="more"><a href="<?php echo $post_type_url; ?>?mtb=h-b-<?php echo $post_type_ID; ?>"><?php printf( $moreText ); ?></a></li>
  146. </ul>
  147. <?php } ?>
  148. </div>
  149. <?php } ?>
  150. </div>
  151. </header>
  152. <div class="inner">
  153. <?php if ( !empty( $types->terms ) ) { ?>
  154. <?php foreach( $types_terms as $type ) { ?>
  155. <?php
  156. $type_url = esc_url(get_term_link($type));
  157. $type_posts_limit = 4;
  158. $type_posts_options = array(
  159. 'tax_query' => array(array(
  160. 'taxonomy' => $type->taxonomy,
  161. 'field' => 'slug',
  162. 'terms' => $type->slug
  163. )),
  164. 'orderby' => 'menu_order',
  165. 'order' => 'ASC',
  166. 'posts_per_page' => $type_posts_limit,
  167. );
  168. ?>
  169. <?php $customQuery = new WP_Query($type_posts_options); ?>
  170. <?php if ( $customQuery->have_posts() ) { ?>
  171. <div class="products articles <?php echo $type->taxonomy; ?>-<?php echo $type->slug; ?>">
  172. <h3 class="title"><?php echo __('Top', 'sandbox'), ' ', $customQuery->post_count, ' ', $type->name; ?></h3>
  173. <div class="inner">
  174. <?php // include(locate_template('loop-archive.php')); ?>
  175. </div>
  176. <div class="content">
  177. <p class="more">
  178. <a href="<?php echo $type_url; ?>" rel="bookmark"><?php echo __('All', 'sandbox'); ?> <?php echo apply_filters('the_title', $type->name); ?></a>
  179. </p>
  180. </div>
  181. </div>
  182. <?php } ?>
  183. <?php } ?>
  184. <?php } ?>
  185. </div>
  186. </section>
  187. <?php } ?>
  188. <?php get_footer() ?>