From fd23367c26802443455e5cfe5ac8e5ed092035fb Mon Sep 17 00:00:00 2001 From: craftwerk Date: Sun, 2 Jul 2023 19:01:23 +0200 Subject: [PATCH 01/11] Add related posts --- inc/related-posts.php | 37 +++++++++++++++++++++++++++++ main.php | 54 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 inc/related-posts.php diff --git a/inc/related-posts.php b/inc/related-posts.php new file mode 100644 index 0000000..fbb326f --- /dev/null +++ b/inc/related-posts.php @@ -0,0 +1,37 @@ + + +
+

Das könnte Sie auch interessieren

+ + + !empty($post) ? $post->ID : '', + 'taxonomy' => 'category', + 'limit' => 3, + 'post_type' => !empty($post) ? $post->post_type : 'post', + 'orderby' => 'date', + 'order' => 'DESC' + )); + + // check taxonomy + if (!taxonomy_exists($args['taxonomy'])) { + return; + } + + // post taxonomies + $taxonomies = wp_get_post_terms($args['post_id'], $args['taxonomy'], array('fields' => 'ids')); + + if (empty($taxonomies)) { + return; + } + + // query + $related_posts = get_posts(array( + 'post__not_in' => (array) $args['post_id'], + 'post_type' => $args['post_type'], + 'tax_query' => array( + array( + 'taxonomy' => $args['taxonomy'], + 'field' => 'term_id', + 'terms' => $taxonomies + ), + ), + 'posts_per_page' => $args['limit'], + 'orderby' => $args['orderby'], + 'order' => $args['order'] + )); + + include(locate_template('inc/related-posts.php', false, false)); + + wp_reset_postdata(); +} +// Related Posts End \ No newline at end of file From 56c5d9194fa86fc23b0d8ba3683ae0e8f66e0f69 Mon Sep 17 00:00:00 2001 From: craftwerk Date: Mon, 3 Jul 2023 13:23:20 +0200 Subject: [PATCH 02/11] Add related posts template --- main.php | 54 ++++++++++++++++++++++++++++++++++++- templates/related-posts.php | 42 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 templates/related-posts.php diff --git a/main.php b/main.php index 7699a70..c15f725 100644 --- a/main.php +++ b/main.php @@ -154,9 +154,16 @@ function bs_swiper_hero_fade() { add_action('wp_head', 'bs_swiper_hero_fade'); +// Related Posts +function bs_swiper_related_posts() { + return bs_swiper_get_template('related-posts.php'); +} +add_action('wp_head', 'bs_swiper_related_posts'); + +/* // Related Posts function bootscore_related_posts($args = array()) { global $post; @@ -203,4 +210,49 @@ function bootscore_related_posts($args = array()) { wp_reset_postdata(); } -// Related Posts End \ No newline at end of file +// Related Posts End +*/ + + +/* +function bootscore_related_posts() { + + $post_id = get_the_ID(); + $cat_ids = array(); + $categories = get_the_category( $post_id ); + + if(!empty($categories) && !is_wp_error($categories)): + foreach ($categories as $category): + array_push($cat_ids, $category->term_id); + endforeach; + endif; + + $current_post_type = get_post_type($post_id); + + $query_args = array( + 'category__in' => $cat_ids, + 'post_type' => $current_post_type, + 'post__not_in' => array($post_id), + 'posts_per_page' => '12', + ); + + $related_cats_post = new WP_Query( $query_args ); + + if($related_cats_post->have_posts()): + while($related_cats_post->have_posts()): $related_cats_post->the_post(); ?> + + term_id); + endforeach; + endif; + + $current_post_type = get_post_type($post_id); + + $query_args = array( + 'category__in' => $cat_ids, + 'post_type' => $current_post_type, + 'post__not_in' => array($post_id), + 'posts_per_page' => '12', + ); + + $related_cats_post = new WP_Query( $query_args ); + + if($related_cats_post->have_posts()): + while($related_cats_post->have_posts()): $related_cats_post->the_post(); ?> + + Date: Mon, 3 Jul 2023 16:27:27 +0200 Subject: [PATCH 03/11] Update related-posts.php --- templates/related-posts.php | 82 +++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 55d09c5..b03a5de 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -22,18 +22,82 @@ function bootscore_related_posts() { ); $related_cats_post = new WP_Query( $query_args ); + ?> + + + + + Date: Mon, 3 Jul 2023 17:05:03 +0200 Subject: [PATCH 04/11] Clean-up code --- inc/related-posts.php | 37 -------- main.php | 97 --------------------- templates/related-posts.php | 163 +++++++++++++++--------------------- 3 files changed, 69 insertions(+), 228 deletions(-) delete mode 100644 inc/related-posts.php diff --git a/inc/related-posts.php b/inc/related-posts.php deleted file mode 100644 index fbb326f..0000000 --- a/inc/related-posts.php +++ /dev/null @@ -1,37 +0,0 @@ - - -
-

Das könnte Sie auch interessieren

- - - !empty($post) ? $post->ID : '', - 'taxonomy' => 'category', - 'limit' => 3, - 'post_type' => !empty($post) ? $post->post_type : 'post', - 'orderby' => 'date', - 'order' => 'DESC' - )); - - // check taxonomy - if (!taxonomy_exists($args['taxonomy'])) { - return; - } - - // post taxonomies - $taxonomies = wp_get_post_terms($args['post_id'], $args['taxonomy'], array('fields' => 'ids')); - - if (empty($taxonomies)) { - return; - } - - // query - $related_posts = get_posts(array( - 'post__not_in' => (array) $args['post_id'], - 'post_type' => $args['post_type'], - 'tax_query' => array( - array( - 'taxonomy' => $args['taxonomy'], - 'field' => 'term_id', - 'terms' => $taxonomies - ), - ), - 'posts_per_page' => $args['limit'], - 'orderby' => $args['orderby'], - 'order' => $args['order'] - )); - - include(locate_template('inc/related-posts.php', false, false)); - - wp_reset_postdata(); -} -// Related Posts End -*/ - - -/* -function bootscore_related_posts() { - - $post_id = get_the_ID(); - $cat_ids = array(); - $categories = get_the_category( $post_id ); - - if(!empty($categories) && !is_wp_error($categories)): - foreach ($categories as $category): - array_push($cat_ids, $category->term_id); - endforeach; - endif; - - $current_post_type = get_post_type($post_id); - - $query_args = array( - 'category__in' => $cat_ids, - 'post_type' => $current_post_type, - 'post__not_in' => array($post_id), - 'posts_per_page' => '12', - ); - - $related_cats_post = new WP_Query( $query_args ); - - if($related_cats_post->have_posts()): - while($related_cats_post->have_posts()): $related_cats_post->the_post(); ?> - - term_id); - endforeach; - endif; - - $current_post_type = get_post_type($post_id); - - $query_args = array( - 'category__in' => $cat_ids, - 'post_type' => $current_post_type, - 'post__not_in' => array($post_id), - 'posts_per_page' => '12', - ); - - $related_cats_post = new WP_Query( $query_args ); - ?> - - - +
- // Restore original Post Data - wp_reset_postdata(); - endif; + + -} \ No newline at end of file + + Date: Mon, 3 Jul 2023 17:27:08 +0200 Subject: [PATCH 05/11] Update related-posts.php --- templates/related-posts.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index dabd6b7..66dd969 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -34,8 +34,7 @@ function bootscore_related_posts() $related_cats_post = new WP_Query($query_args); ?> - Date: Thu, 13 Jul 2023 10:01:34 +0200 Subject: [PATCH 06/11] Change related posts to default card layout --- templates/related-posts.php | 59 ++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 66dd969..650d9b4 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -6,11 +6,10 @@ * * @author bootScore * @package bS Swiper - * @version 5.3.0 + * @version 5.3.0 */ -function bootscore_related_posts() -{ +function bootscore_related_posts() { $post_id = get_the_ID(); $cat_ids = array(); @@ -46,18 +45,50 @@ function bootscore_related_posts() while ($related_cats_post->have_posts()) : $related_cats_post->the_post(); ?> -
- - 'card-img-top')); ?> -
- - -

- -

+
+

+ +

+ + + +

+ + + +
+ +
From 2d3916934207a4b8fb8bc875212a1ffae5295b0a Mon Sep 17 00:00:00 2001 From: craftwerk Date: Thu, 13 Jul 2023 10:06:34 +0200 Subject: [PATCH 07/11] Formatting --- templates/related-posts.php | 2 +- templates/sc-swiper-card-autoplay.php | 2 +- templates/sc-swiper-card-product.php | 2 +- templates/sc-swiper-card.php | 2 +- templates/sc-swiper-hero-fade.php | 2 +- templates/sc-swiper-hero.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 650d9b4..ec35fc4 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -6,7 +6,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.3.0 + * @version 5.3.0 */ function bootscore_related_posts() { diff --git a/templates/sc-swiper-card-autoplay.php b/templates/sc-swiper-card-autoplay.php index 1da93cd..bd792a0 100644 --- a/templates/sc-swiper-card-autoplay.php +++ b/templates/sc-swiper-card-autoplay.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.1 + * @version 5.2.1 Posts: diff --git a/templates/sc-swiper-card-product.php b/templates/sc-swiper-card-product.php index ad36a58..fe2ae94 100644 --- a/templates/sc-swiper-card-product.php +++ b/templates/sc-swiper-card-product.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Product Slider Shortcode [bs-swiper-card-product order="DESC" orderby="date" posts="12" category="theme, child-themes, free, plugins"] diff --git a/templates/sc-swiper-card.php b/templates/sc-swiper-card.php index 2ae696d..9842f36 100644 --- a/templates/sc-swiper-card.php +++ b/templates/sc-swiper-card.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.1 + * @version 5.2.1 Posts: diff --git a/templates/sc-swiper-hero-fade.php b/templates/sc-swiper-hero-fade.php index 738417e..a778f23 100644 --- a/templates/sc-swiper-hero-fade.php +++ b/templates/sc-swiper-hero-fade.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Posts: [bs-swiper-hero-fade type="post" category="cars, boats" order="ASC" orderby="date" posts="6"] diff --git a/templates/sc-swiper-hero.php b/templates/sc-swiper-hero.php index 9e7abce..8522bfe 100644 --- a/templates/sc-swiper-hero.php +++ b/templates/sc-swiper-hero.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Posts: [bs-swiper-hero type="post" category="cars, boats" order="ASC" orderby="date" posts="6"] From f6f172508ac6bd649a975bccb8fc12f070c062e2 Mon Sep 17 00:00:00 2001 From: craftwerk Date: Thu, 13 Jul 2023 10:09:45 +0200 Subject: [PATCH 08/11] Formatting --- templates/related-posts.php | 2 +- templates/sc-swiper-card-autoplay.php | 2 +- templates/sc-swiper-card-product.php | 2 +- templates/sc-swiper-card.php | 2 +- templates/sc-swiper-hero-fade.php | 2 +- templates/sc-swiper-hero.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index ec35fc4..650d9b4 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -6,7 +6,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.3.0 + * @version 5.3.0 */ function bootscore_related_posts() { diff --git a/templates/sc-swiper-card-autoplay.php b/templates/sc-swiper-card-autoplay.php index bd792a0..1da93cd 100644 --- a/templates/sc-swiper-card-autoplay.php +++ b/templates/sc-swiper-card-autoplay.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.1 + * @version 5.2.1 Posts: diff --git a/templates/sc-swiper-card-product.php b/templates/sc-swiper-card-product.php index fe2ae94..ad36a58 100644 --- a/templates/sc-swiper-card-product.php +++ b/templates/sc-swiper-card-product.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Product Slider Shortcode [bs-swiper-card-product order="DESC" orderby="date" posts="12" category="theme, child-themes, free, plugins"] diff --git a/templates/sc-swiper-card.php b/templates/sc-swiper-card.php index 9842f36..2ae696d 100644 --- a/templates/sc-swiper-card.php +++ b/templates/sc-swiper-card.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.1 + * @version 5.2.1 Posts: diff --git a/templates/sc-swiper-hero-fade.php b/templates/sc-swiper-hero-fade.php index a778f23..738417e 100644 --- a/templates/sc-swiper-hero-fade.php +++ b/templates/sc-swiper-hero-fade.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Posts: [bs-swiper-hero-fade type="post" category="cars, boats" order="ASC" orderby="date" posts="6"] diff --git a/templates/sc-swiper-hero.php b/templates/sc-swiper-hero.php index 8522bfe..9e7abce 100644 --- a/templates/sc-swiper-hero.php +++ b/templates/sc-swiper-hero.php @@ -7,7 +7,7 @@ * * @author bootScore * @package bS Swiper - * @version 5.2.0 + * @version 5.2.0 Posts: [bs-swiper-hero type="post" category="cars, boats" order="ASC" orderby="date" posts="6"] From a603f4132ae1864c6393330b20ca654639387c57 Mon Sep 17 00:00:00 2001 From: craftwerk Date: Thu, 13 Jul 2023 19:23:21 +0200 Subject: [PATCH 09/11] Update related-posts.php --- templates/related-posts.php | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 650d9b4..6987c4a 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -55,37 +55,22 @@ function bootscore_related_posts() {
- - - ', ''); ?> + ', ''); ?> - -

- -

- - -

- +

+

-

+

- -
From 0e1a25f8b55f8147ed1e9c5fb53e88e235fc2485 Mon Sep 17 00:00:00 2001 From: craftwerk Date: Fri, 14 Jul 2023 10:54:24 +0200 Subject: [PATCH 10/11] Update related-posts.php --- templates/related-posts.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 6987c4a..cc8eb5d 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -48,29 +48,24 @@ function bootscore_related_posts() {
- - 'card-img-top')); ?> - + 'card-img-top')); ?>
- - ', ''); ?> - + ', ''); ?> -

- - - +

+

- +

+
From 4261c2184adbaf2ccfa03ab5027de2aaa56c0bcb Mon Sep 17 00:00:00 2001 From: craftwerk Date: Fri, 14 Jul 2023 10:59:33 +0200 Subject: [PATCH 11/11] Truncate heading --- templates/related-posts.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index cc8eb5d..73d7f3b 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -53,9 +53,9 @@ function bootscore_related_posts() {
- ', ''); ?> + ', ''); ?> -

+

@@ -65,7 +65,6 @@ function bootscore_related_posts() {

-