1
0
Răsfoiți Sursa

Fixed #6: shortcode for partners boxes, rewrite partner to initiativpartner

Moritz Schmidt 9 ani în urmă
părinte
comite
74c1d9b490
2 a modificat fișierele cu 40 adăugiri și 7 ștergeri
  1. 39 6
      functions.php
  2. 1 1
      index.php

+ 39 - 6
functions.php

@@ -48,21 +48,22 @@ function create_post_types() {
         'singular_name' => __( 'Partner' )
       ),
       'public' => true,
-      'has_archive' => true,
+      'has_archive' => false,
       'menu_icon' => 'dashicons-admin-users',
       'supports' => array('title', 'editor', 'thumbnail'),
-      'exlude_from_search' => true
+      'exlude_from_search' => true,
+      'rewrite' => array('slug' => 'initiativpartner'),
     )
   );
 
   register_post_type( 'tdas',
     array(
       'labels' => array(
-        'name' => __( 'TdA' ),
-        'singular_name' => __( 'TdA' )
+        'name' => __( 'Tag der Architektur' ),
+        'singular_name' => __( 'Tag der Architektur' )
       ),
       'public' => true,
-      'has_archive' => true,
+      'has_archive' => false,
       'menu_icon' => 'dashicons-calendar-alt',
       'supports' => array('title', 'editor', 'thumbnail'),
       'rewrite' => array('slug' => 'tag-der-architektur'),
@@ -76,7 +77,7 @@ function create_post_types() {
         'singular_name' => __( 'Projekt' )
       ),
       'public' => true,
-      'has_archive' => true,
+      'has_archive' => false,
       'menu_icon' => 'dashicons-calendar-alt',
       'supports' => array('title', 'editor', 'thumbnail'),
       'rewrite' => array('slug' => 'projekte'),
@@ -705,6 +706,38 @@ function hoverboxes_shortcode_func($atts) {
 
 add_shortcode('hoverboxes', 'hoverboxes_shortcode_func');
 
+function partnersboxes_shortcode_func($atts) {
+  $output = "";
+
+  $partnerQuery = new WP_Query( array( 'post_type' => 'partners', 'order' => 'ASC' ) );
+  if($partnerQuery->have_posts()) {
+      $output .= "<div id=\"partners\" class=\"container text-muted\">" . PHP_EOL;
+        $output .= "<div class=\"row\">" . PHP_EOL;
+          while($partnerQuery->have_posts()) {
+            $partnerQuery->the_post();
+            $output .= "<div class=\"col-md-4\">" . PHP_EOL;
+              $output .= "<div class=\"card\">" . PHP_EOL;
+                if(has_post_thumbnail()) {
+                  $output .= get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'card-img-top')) . PHP_EOL;
+                }
+                $output .= "<div class=\"card-block\">" . PHP_EOL;
+                  $output .= "<h4 class=\"card-title\">" . get_the_title() . "</h4>" . PHP_EOL;
+                  $output .= "<p class=\"card-text\">" . PHP_EOL;
+                    $output .= get_the_content() . PHP_EOL;
+                  $output .= "</p>" . PHP_EOL;
+                $output .= "</div>" . PHP_EOL;
+              $output .= "</div>" . PHP_EOL;
+            $output .= "</div>" . PHP_EOL;
+          }
+        $output .= "</div>" . PHP_EOL;
+    wp_reset_postdata();
+  }
+
+  return $output;
+}
+
+add_shortcode('partnersboxes', 'partnersboxes_shortcode_func');
+
 /* TITLE STUFF */
 
 function ams_modify_titles($title, $id = null) {

+ 1 - 1
index.php

@@ -244,7 +244,7 @@
         echo "404"; // TODO: this
       }
     } else {
-      the_title();
+      error_log("YOOO");
     } ?>
 
     </div><?php