$value) { $categories[] = $value['value']; } } else { $categories = array(); } if (isset($attributes['tags']) && ! empty($attributes['tags']) && is_array($attributes['tags'])) { $tags = array(); $i = 1; foreach ($attributes['tags'] as $key => $value) { $tags[] = $value['value']; } } else { $tags = array(); } /* Setup the query */ $currentID = get_the_ID(); $query_args = array( 'posts_per_page' => $attributes['postsToShow'], 'post_status' => 'publish', 'order' => $attributes['order'], 'orderby' => $attributes['orderBy'], 'offset' => ($attributes['enablePagination'] == 'true') ? '' : $attributes['offset'], 'post_type' => $attributes['postType'], 'ignore_sticky_posts' => 1, 'paged' => $paged, 'post__not_in' => array($currentID) ); if ('post' != $attributes['postType']) { $tax_type = $attributes['taxType']; if ($tax_type) { if (!empty($categories)) { $query_args['tax_query'][] = array( 'taxonomy' => (isset($tax_type)) ? $tax_type : 'category', 'field' => 'id', 'terms' => $categories, 'operator' => 'IN', ); } } } if ('post' == $attributes['postType']) { $tax_type = $attributes['taxType']; if ($tax_type) { if (!empty($categories)) { $query_args['tax_query'][] = array( 'taxonomy' => (isset($tax_type)) ? $tax_type : 'category', 'field' => 'id', 'terms' => $categories, 'operator' => 'IN', ); } else { $taxonomy = $tax_type; // this is the name of the taxonomy $terms = get_terms($taxonomy); if (!empty($terms)) { $query_args['tax_query'][] = array( 'taxonomy' => (isset($tax_type)) ? $tax_type : 'category', 'field' => 'slug', 'terms' => wp_list_pluck($terms, 'slug') ); } } } } if ($attributes['taxType'] == 'category') { $query_args['category__in'] = $categories; } if ($attributes['taxType'] == 'post_tag') { $query_args['tag__in'] = $tags; } /* Setup the query */ $grid_query = new WP_Query($query_args); return $grid_query; } function blockspare_query_loop_and_wrapper($attributes, $blockclass = '', $design = '', $blockName = '', $paged = '', $layoutClass = false) { if ($attributes['enablePagination']) { wp_enqueue_script('blockspare-pagination-js'); } $unq_class = mt_rand(100000, 999999); $blockuniqueclass = ''; if (!empty($attributes['uniqueClass'])) { $blockuniqueclass = $attributes['uniqueClass']; } else { $blockuniqueclass = 'blockspare-posts-block-list-' . $unq_class; } $grid_query = blockspare_post_query($attributes); if ($grid_query->have_posts()) { $alignclass = blockspare_checkalignment($attributes['align']); /* Build the block classes */ $class = "wp-block-blockspare-posts-block-blockspare-posts-block-latest-posts align" . $alignclass . " " . $attributes['blockHoverEffect']; if (isset($attributes['className'])) { $class .= ' ' . $attributes['className']; } if ($attributes['animation']) { $class .= ' blockspare-block-animation'; } $list_layout_class = $design; $listgridClass = $blockclass . " "; // if($blockName=='' ){ // $listgridClass .= "column-" . $attributes['columns']; // } /* Layout orientation class */ $grid_class = 'blockspare-posts-block-latest-post-wrap ' . $listgridClass . ' ' . $list_layout_class; // if ($blockName != 'post-grid-masonry'){ // $grid_class .= ' ' . $blockuniqueclass; // }else{ $class .= ' ' . $blockuniqueclass; // } $category_class = 'blockspare-posts-block-post-category'; if ($attributes['categoryLayoutOption'] == 'none') { $category_class .= ' has-no-category-style'; } $enableFeatureImage = true; if (isset($attributes['enableFeatureImage'])) { $enableFeatureImage = $attributes['enableFeatureImage']; } ?>
have_posts()) { $grid_query->the_post(); /* Setup the post ID */ $post_id = get_the_ID(); /* Setup the featured image ID */ $post_thumb_id = get_post_thumbnail_id($post_id); $has_img_class = ''; if (!$post_thumb_id) { $has_img_class = "post-has-no-image "; } if (isset($attributes['full'])) { if ($attributes['full'] == 'blockspare-posts-block-full-layout-4') { $attributes['enableEqualHeight'] = false; } } if ($attributes['enableEqualHeight']) { $has_img_class .= 'bs-has-equal-height'; } $contentOrderClass = ''; if ($attributes['contentOrder'] == 'content-order-1') { $contentOrderClass .= 'contentorderone'; } if ($attributes['contentOrder'] == 'content-order-2') { $contentOrderClass .= 'contentordertwo'; } /* Setup the post classes */ $post_classes = 'blockspare-posts-block-post-single blockspare-hover-item ' . $contentOrderClass; if ($layoutClass) { $post_classes .= ' has-background'; } else { $post_classes .= ' blockspare-hover-child'; } $className = ''; if (isset($attributes['full'])) { if ($attributes['full'] == 'blockspare-posts-block-full-layout-6') { $post_classes .= ' blockspare-hover-child'; $className .= 'hover-child'; } } /* Add sticky class */ if (is_sticky($post_id)) { $post_classes .= ' sticky'; } else { $post_classes .= null; } if ($blockName == 'post-grid-masonry') { ?>
max_num_pages > 1) { $loadmore_class = ''; if ($attributes['loadMoreStyle']) { $loadmore_class = $attributes['loadMoreStyle']; } if ($attributes['loadMoreAlignment']) { $loadmore_class .= ' bs_blockspare_loadmore_' . $attributes['loadMoreAlignment']; } ?>
max-paged="max_num_pages; ?>">

.*\<\/figcaption>/', '/\[caption.*\[\/caption\]/', '`[[^]]*]`' ), '', get_the_content() ); } // Trim the excerpt if necessary. if (isset($length)) { $excerpt = wp_trim_words( $excerpt, $length ); } return $excerpt; }