first_product ) { return $this->first_product; } $args = array( 'post_type' => 'product', 'post_status' => array( 'publish', 'pending', 'draft', 'future' ), 'posts_per_page' => 1, ); $sample_product = get_post_meta( $this->get_main_id(), '_sample_product', true ); if ( $sample_product ) { $args['p'] = $sample_product; } $wp_query = new WP_Query( $args ); if ( ! $wp_query->have_posts() ) { return false; } $post = $wp_query->posts; return $this->first_product = $post[0]->ID; } /** * Query for first product ID. * * @return int|bool */ public function query_first_category() { if ( null !== $this->first_category ) { return $this->first_category; } $product_categories = get_categories( array( 'taxonomy' => 'product_cat', 'orderby' => 'name', 'pad_counts' => false, 'hierarchical' => 1, 'hide_empty' => false ) ); if ( ! empty( $product_categories ) ) { $product_category = $product_categories[0]; } return $this->first_category = $product_category->term_id; } /** * Save meta for current post * @param $post_id */ public function save_template_item_to_meta( $post_id ) { $content = Elementor\Plugin::instance()->frontend->get_builder_content( $post_id, false ); $content = preg_replace( '/