summaryrefslogtreecommitdiff
path: root/angebote/inc/template.php
diff options
context:
space:
mode:
authorMax2019-02-17 17:20:43 +0100
committerMax2019-02-17 17:20:43 +0100
commitc4b2eb526c5733cc32b0550eb76fd072531e223c (patch)
tree9e3355627357ca392ae26574c81181bf33bd028e /angebote/inc/template.php
parent43a8c0fe50529a6b4161d12f087925c06ce37574 (diff)
downloadfuselkoenig_de-c4b2eb526c5733cc32b0550eb76fd072531e223c.tar.gz
Creates custom post type and custom taxonomy and renders them correctly.
Diffstat (limited to 'angebote/inc/template.php')
-rw-r--r--angebote/inc/template.php107
1 files changed, 107 insertions, 0 deletions
diff --git a/angebote/inc/template.php b/angebote/inc/template.php
new file mode 100644
index 0000000..d0bbcc3
--- /dev/null
+++ b/angebote/inc/template.php
@@ -0,0 +1,107 @@
+<?php
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+function render_offer_template( $atts ) {
+ global $post;
+ $categories = get_the_terms( $post, 'type' );
+ $spirit_type = 'Verschiedenes';
+
+ if ( isset($categories[0]) ) {
+ $spirit_type = $categories[0]->name;
+ }
+
+ $include_post_link = false;
+ if ( is_archive() || is_search() ) {
+ $include_post_link = true;
+ }
+ if ( is_search() ) {
+ $css_border_left = " card-border-left";
+ } else {
+ $css_border_left = "";
+ }
+
+ $offer = shortcode_atts( array(
+ 'spirit_type' => $spirit_type,
+ 'shop' => '',
+ 'procent' => '',
+ 'img_url' => '',
+ 'name' => '',
+ 'discounted_price' => '',
+ 'original_price' => '',
+ 'shipping_costs' => 'Versand ist nie kostenlos',
+ 'abv' => '',
+ 'volume' => '',
+ 'base_price' => '',
+ 'url' => '',
+ 'created_at' => '',
+ 'include_post_link' => $include_post_link,
+ ), $atts
+ );
+?>
+ <div class="card <?php echo $css_border_left; ?>">
+ <div class="row ">
+ <div class="col-md-4">
+ <div class="card-header-dp-none">
+ <p><strong>
+ <span style="visibility: hidden;">
+ <?php echo $offer['spirit_type']; ?><span class="float-right"><?php echo $offer['shop']; ?></span>
+ </span>
+ </strong></p>
+ </div>
+ <div class="card-img-overlay card-img-overlay-badge" >
+ <p class="card-text float-right rounded off-badge" ><?php echo $offer['procent']; ?> %</p>
+ </div>
+ <img src="<?php echo $offer['img_url']; ?>" class="w-100 card-img img-fluid" >
+ </div>
+ <div class="col-md-8 px-10">
+ <div class="card-header">
+ <p><strong>
+ <?php echo $offer['spirit_type']; ?><span class="float-right"><?php echo $offer['shop']; ?></span>
+ </strong></p>
+ </div>
+ <div class="card-block card-body px-3">
+<?php
+ if ( $offer['include_post_link'] ) {
+?>
+ <h3 class="card-title"><a class="offer-title" href="<?php echo get_post_permalink( $post ); ?>" title="<?php echo $offer['name']; ?>"><?php echo $offer['name']; ?> <i class="material-icons icon-small" sstyle="font-size: 50%;">
+launch
+</i></a></h3>
+<?php
+ } else {
+?>
+ <h3 class="card-title"><?php echo $offer['name']; ?></h3>
+<?php
+ }
+?>
+ <div class="row">
+ <p class="card-text col-md-6">
+ Preis: <?php echo $offer['discounted_price']; ?> €
+ <br>
+ Alter Preis: <?php echo $offer['original_price']; ?> €
+ <br>
+ Versand: <?php echo $offer['shipping_costs']; ?> €
+ </p>
+ <p class="card-text col-md-6">
+ Alkohol: <?php echo $offer['abv']; ?> %
+ <br>
+ Volumen: <?php echo $offer['volume']; ?> Liter
+ <br>
+ <?php echo $offer['base_price']; ?> € / Liter
+ </p>
+ </div>
+ </div>
+ <div class="card-footer">
+ <a href="<?php echo $offer['url']; ?>" class="btn btn-primary">Zum Shop</a>
+ <!--p class="float-right">Preis vom <?php echo $offer['created_at']; ?></p-->
+ </div>
+ </div>
+
+ </div>
+ </div>
+<?php
+}
+
+add_shortcode('angebot', 'render_offer_template');