diff --git a/assets/scss/patterns/_index.scss b/assets/scss/patterns/_index.scss index dc09d89..c6b30dd 100644 --- a/assets/scss/patterns/_index.scss +++ b/assets/scss/patterns/_index.scss @@ -1,3 +1,2 @@ // 'patterns/' houses styles for custom patterns. // @import './pattern-name'; -@import './related-posts'; diff --git a/assets/scss/patterns/related-posts.scss b/assets/scss/patterns/related-posts.scss deleted file mode 100644 index e87d83c..0000000 --- a/assets/scss/patterns/related-posts.scss +++ /dev/null @@ -1,19 +0,0 @@ -/** cards **/ - -.related-posts-query { - .wp-block-post { - .wp-block-read-more { - color: var(--wp--preset--color--primary-500); - font-size: var(--wp--preset--font-size--xxs); - font-weight: 300; - margin-bottom: 0.75rem; - margin-top: 0.75rem; - text-decoration: underline; - - &:hover, - &:focus { - color: var(--wp--preset--color--primary-300); - } - } - } -} diff --git a/inc/functions/related-posts-query.php b/inc/functions/related-posts-query.php deleted file mode 100644 index 3f5774d..0000000 --- a/inc/functions/related-posts-query.php +++ /dev/null @@ -1,73 +0,0 @@ -standalone->primaryTerm->getPrimaryTerm( $current_id, 'category' ); - - if ( is_a( $primary_cat, 'WP_Term' ) ) { - $cat_id = $primary_cat->term_id; - } - } elseif ( class_exists( '\WPSEO_Primary_Term' ) ) { - // Show the post's 'Primary' category if this Yoast feature is available and one is set. - $primary_term = new \WPSEO_Primary_Term( 'category', $current_id ); - $primary_term_id = $primary_term->get_primary_term(); - $term = get_term( $primary_term_id ); - - if ( ! is_wp_error( $term ) && $term ) { - $cat_id = $term->term_id; - } - } - - // If no primary category found, include all categories. - if ( empty( $cat_id ) ) { - $cat_ids = wp_list_pluck( $category, 'term_id' ); - $cat_id = implode( ',', $cat_ids ); - } - } - - // Check if the block has the class 'related-posts-query'. - if ( isset( $block->parsed_block['attrs']['className'] ) && 'related-posts-query' === $block->parsed_block['attrs']['className'] ) { - $query_vars['post_type'] = 'any'; - $query_vars['cat'] = $cat_id; - $query_vars['posts_per_page'] = 3; - $query_vars['post__not_in'] = array( get_the_ID() ); - $query_vars['orderby'] = 'date'; - $query_vars['order'] = 'desc'; - $query_vars['nopaging'] = true; - $query_vars['tax_query'] = array( - 'taxonomy' => 'category', - 'field' => 'id', - 'terms' => $cat_id, - ); - } - - // Return the modified query variables. - return $query_vars; -} -add_filter( 'query_loop_block_query_vars', __NAMESPACE__ . '\related_posts_query', 10, 2 ); diff --git a/inc/hooks/register-block-patterns.php b/inc/hooks/register-block-patterns.php index 57a1af5..cb63607 100644 --- a/inc/hooks/register-block-patterns.php +++ b/inc/hooks/register-block-patterns.php @@ -13,14 +13,14 @@ function register_custom_block_pattern() { register_block_pattern( - 'wdsbt/related-posts', + 'wdsbt/pattern-name', array( - 'title' => __( 'Related Posts', 'wdsbt' ), + 'title' => __( 'Pattern Title', 'wdsbt' ), 'blockTypes' => array( 'core/query' ), 'templateTypes' => array( 'single-post' ), 'postTypes' => array( '' ), - 'description' => _x( 'Related Posts query variation', 'Block pattern description', 'wdsbt' ), - 'content' => '', + 'description' => _x( 'Block Pattern Name', 'Block pattern description', 'wdsbt' ), + 'content' => '', ) ); } diff --git a/templates/single.html b/templates/single.html index 54ea82c..dd052a5 100644 --- a/templates/single.html +++ b/templates/single.html @@ -29,14 +29,6 @@ - -