array( $this, 'render_callback' ), ) ); } public function get_label() { return __( 'Recent Posts', 'getwid' ); } public function render_callback( $attributes, $content ) { $query_args = array( 'posts_per_page' => $attributes['postsToShow'], 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'order' => $attributes['order'], 'orderby' => $attributes['orderBy'], ); if ( isset( $attributes['categories'] ) ) { $query_args['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $attributes['categories'], ), ); } $block_name = 'wp-block-getwid-recent-posts'; $extra_attr = array( 'block_name' => $block_name, ); $class = $block_name; if ( isset( $attributes['align'] ) ) { $class .= ' align' . $attributes['align']; } if ( isset( $attributes['postLayout'] ) ) { $class .= ' has-layout-' . $attributes['postLayout']; } if ( isset( $attributes['showPostDate'] ) && $attributes['showPostDate'] ) { $class .= ' has-dates'; } if ( isset( $attributes['className'] ) ) { $class .= ' ' . $attributes['className']; } if ( isset( $attributes['cropImages'] ) && true === $attributes['cropImages'] ) { $class .= ' has-cropped-images'; } $wrapper_class = $block_name . '__wrapper'; if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) { $wrapper_class .= ' getwid-columns getwid-columns-' . $attributes['columns']; } $attributes['titleTag'] = $this->validate_heading_html_tag( $attributes['titleTag'] ); $q = new \WP_Query( $query_args ); ob_start(); ?>