start_controls_section( 'section_title', [ 'label' => esc_html__( 'Columns', 'elementor' ), ] ); $this->add_control( 'posts_per_page', [ 'label' => esc_html__( 'Items Per Page', 'elementor-pro' ), 'type' => Controls_Manager::NUMBER, 'default' => 3, 'min' => 1, ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_title_style', [ 'label' => esc_html__( 'Box', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'section_title_box_margin', [ 'label' => esc_html__( 'Gap', 'elementor-pro' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-categories-list .elementor-category-box:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_posts_image_style', [ 'label' => esc_html__( 'Image', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'section_posts_image_style_width', [ 'label' => esc_html__( 'Width', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'unit' => '%', ], 'tablet_default' => [ 'unit' => '%', ], 'mobile_default' => [ 'unit' => '%', ], 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'range' => [ '%' => [ 'min' => 1, 'max' => 100, ], 'px' => [ 'min' => 1, 'max' => 1000, ], 'vw' => [ 'min' => 1, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-img .elementor-category-box-img-link img' => 'width: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'section_posts_image_style_height', [ 'label' => esc_html__( 'Height', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 500, ], 'vh' => [ 'min' => 1, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-img .elementor-category-box-img-link img' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'section_posts_image_style_object_fit', [ 'label' => esc_html__( 'Object Fit', 'elementor' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => esc_html__( 'Default', 'elementor' ), 'fill' => esc_html__( 'Fill', 'elementor' ), 'cover' => esc_html__( 'Cover', 'elementor' ), 'contain' => esc_html__( 'Contain', 'elementor' ), 'scale-down' => esc_html__( 'Scale Down', 'elementor' ), ], 'default' => '', 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-img .elementor-category-box-img-link img' => 'object-fit: {{VALUE}};', ], ] ); $this->add_responsive_control( 'section_posts_image_style_object_position', [ 'label' => esc_html__( 'Object Position', 'elementor' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'center center' => esc_html__( 'Center Center', 'elementor' ), 'center left' => esc_html__( 'Center Left', 'elementor' ), 'center right' => esc_html__( 'Center Right', 'elementor' ), 'top center' => esc_html__( 'Top Center', 'elementor' ), 'top left' => esc_html__( 'Top Left', 'elementor' ), 'top right' => esc_html__( 'Top Right', 'elementor' ), 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ), 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ), 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ), ], 'default' => 'center center', 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-img .elementor-category-box-img-link img' => 'object-position: {{VALUE}};', ], ] ); $this->add_responsive_control( 'section_posts_image_style_margin', [ 'label' => esc_html__( 'Margin', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_posts_title_style', [ 'label' => esc_html__( 'Title', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'section_posts_title_style_color', [ 'label' => esc_html__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_PRIMARY, ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-title .elementor-category-box-title-link' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'section_posts_title_style_typography', 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], 'selector' => '{{WRAPPER}} .elementor-category-box .elementor-category-box-title .elementor-category-box-title-link', ] ); $this->add_responsive_control( 'section_posts_title_style_margin', [ 'label' => esc_html__( 'Margin', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_posts_info_style', [ 'label' => esc_html__( 'Info', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'section_posts_info_style_color', [ 'label' => esc_html__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_PRIMARY, ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-info' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'section_posts_info_style_typography', 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], 'selector' => '{{WRAPPER}} .elementor-category-box .elementor-category-box-info', ] ); $this->add_responsive_control( 'section_posts_info_style_margin', [ 'label' => esc_html__( 'Margin', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-info' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_posts_description_style', [ 'label' => esc_html__( 'Description', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'section_posts_description_style_color', [ 'label' => esc_html__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_PRIMARY, ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-description' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'section_posts_description_style_typography', 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], 'selector' => '{{WRAPPER}} .elementor-category-box .elementor-category-box-description', ] ); $this->add_responsive_control( 'section_posts_description_style_margin', [ 'label' => esc_html__( 'Margin', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box .elementor-category-box-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // ---------------------------------------------------------------------------------------------------- $this->start_controls_section( 'section_posts_btn_style', [ 'label' => esc_html__( 'Button', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'section_posts_btn_style_color', [ 'label' => esc_html__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_PRIMARY, ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'section_posts_btn_style_typography', 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], 'selector' => '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link', ] ); $this->add_responsive_control( 'section_posts_btn_style_margin', [ 'label' => esc_html__( 'Margin', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'section_posts_btn_style_padding', [ 'label' => esc_html__( 'Padding', 'elementor-pro' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'read_more_flex', [ 'label' => esc_html__( 'Position', 'elementor-pro' ), 'type' => Controls_Manager::CHOOSE, 'label_block' => false, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'elementor-pro' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'elementor-pro' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'elementor-pro' ), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'left', 'selectors' => [ '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link' => 'display: flex; align-items: center; justify-content: {{VALUE}};', ], ] ); $this->add_responsive_control( 'section_posts_btn_style_gap', [ 'label' => esc_html__( 'Gap', 'elementor-pro' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .elementor-category-box-btn .elementor-category-box-btn-link img' => 'margin-left: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings(); $category = get_the_category(); $posts = get_posts( array( 'category__in' => array_column( $category, 'term_id' ), 'post__not_in' => array( get_the_ID() ), 'posts_per_page' => $this->get_settings( 'posts_per_page' ), ) ); if ( empty( $posts ) ) { return; } ?>