start_controls_section( 'blog_grid', [ 'label' => esc_html__( 'Thinkai Blog Grid', 'thinkai' ), ] ); $this->add_control( 'layout_control', [ 'label' => esc_html__( 'Layout Style', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => '1', 'options' => array( '1' => esc_html__( 'Style One', 'thinkai'), '2' => esc_html__( 'Style Two', 'thinkai'), '3' => esc_html__( 'Style Three', 'thinkai'), ), ] ); //Author $this->add_control( 'author', [ 'label' => esc_html__( 'Show Author', 'thinkai' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'On', 'thinkai' ), 'label_off' => esc_html__( 'Off', 'thinkai' ), 'return_value' => 'yes', 'default' => 'yes', ] ); //Date $this->add_control( 'date', [ 'label' => esc_html__( 'Show Date', 'thinkai' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'On', 'thinkai' ), 'label_off' => esc_html__( 'Off', 'thinkai' ), 'return_value' => 'yes', 'default' => 'yes', ] ); //category $this->add_control( 'category', [ 'label' => esc_html__( 'Show category', 'thinkai' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'On', 'thinkai' ), 'label_off' => esc_html__( 'Off', 'thinkai' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'query_number', [ 'label' => esc_html__( 'Number of post', 'thinkai' ), 'type' => Controls_Manager::NUMBER, 'default' => 3, 'min' => 1, 'max' => 100, 'step' => 1, ] ); $this->add_control( 'query_orderby', [ 'label' => esc_html__( 'Order By', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => 'date', 'options' => array( 'date' => esc_html__( 'Date', 'thinkai' ), 'title' => esc_html__( 'Title', 'thinkai' ), 'menu_order' => esc_html__( 'Menu Order', 'thinkai' ), 'rand' => esc_html__( 'Random', 'thinkai' ), ), ] ); $this->add_control( 'query_order', [ 'label' => esc_html__( 'Order', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => 'DESC', 'options' => array( 'DESC' => esc_html__( 'DESC', 'thinkai' ), 'ASC' => esc_html__( 'ASC', 'thinkai' ), ), ] ); $this->add_control( 'query_category', [ 'type' => Controls_Manager::SELECT, 'label' => esc_html__('Category', 'thinkai'), 'label_block' => true, 'multiple' => true, 'options' => get_blog_categories() ] ); //Pagination $this->add_control( 'show_pagination', [ 'label' => __( 'Enable/Disable Pagination Style', 'thinkai' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Show', 'thinkai' ), 'label_off' => __( 'Hide', 'thinkai' ), 'return_value' => 'yes', 'default' => 'no', 'condition' => ['layout_control' => ['1','3'] ], ] ); $this->end_controls_section(); /**Grid Setting Start**/ $this->start_controls_section( 'grid', [ 'label' => esc_html__( 'Grid Setting', 'thinkai' ), ] ); $this->add_control( 'col_grid', [ 'label' => esc_html__( 'Choose Column', 'thinkai' ), 'label_block' => true, 'type' => Controls_Manager::SELECT, 'default' => 'three', 'options' => array( 'one' => esc_html__( 'One Column Grid ', 'thinkai'), 'two' => esc_html__( 'Two Column Grid', 'thinkai' ), 'three' => esc_html__( 'Three Column Grid', 'thinkai' ), 'four' => esc_html__( 'Four Column Grid', 'thinkai' ), 'five' => esc_html__( 'Six Column Grid', 'thinkai' ), ), ] ); $this->end_controls_section(); } /** * Render button widget output on the frontend. * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $allowed_tags = wp_kses_allowed_html('post'); $layout = $settings[ 'layout_control' ]; $grid_col = $settings['col_grid']; if( $grid_col == 'one' ){ $classes = 'col-xl-12 col-lg-12 col-md-12 col-sm-12'; }elseif( $grid_col == 'two' ){ $classes = 'col-xl-6 col-lg-6 col-md-12 col-sm-12'; }elseif( $grid_col == 'four' ){ $classes = 'col-xl-3 col-lg-3 col-md-12 col-sm-12'; }elseif( $grid_col == 'five' ){ $classes = 'col-xl-2 col-lg-2 col-md-12 col-sm-12'; }else{ $classes = 'col-xl-4 col-lg-4 col-md-12 col-sm-12'; }; $category = $settings[ 'category' ]; $date = $settings[ 'date' ]; $author = $settings[ 'author' ]; $paged = get_query_var('paged'); $paged = thinkai_set($_REQUEST, 'paged') ? esc_attr($_REQUEST['paged']) : $paged; $this->add_render_attribute( 'wrapper', 'class', 'templatepath-thinkai' ); $argst = array( 'post_type' => 'post', 'posts_per_page' => thinkai_set( $settings, 'query_number' ), 'orderby' => thinkai_set( $settings, 'query_orderby' ), 'order' => thinkai_set( $settings, 'query_order' ), 'paged' => $paged ); if( thinkai_set( $settings, 'query_category' ) ) $args['category_name'] = thinkai_set( $settings, 'query_category' ); $query = new \WP_Query( $argst ); if ( $query->have_posts() ) { ?>
have_posts() ) : $query->the_post(); $post_thumbnail_id = get_post_thumbnail_id($post->ID); $post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id); ?>
$query->max_num_pages, 'next_text' => 'Next Page ', 'prev_text' => ' Prev Page')); ?>
have_posts() ) : $query->the_post(); ?>
have_posts() ) : $query->the_post(); ?>
$query->max_num_pages, 'next_text' => 'Next Page ', 'prev_text' => ' Prev Page')); ?>