start_controls_section( 'section_my_custom', [ 'label' => esc_html__( 'Blog Posts', 'brad' ), ] ); $this->add_control( 'posts_per_page', [ 'label' => esc_html__( 'Number of Posts', 'brad' ), 'type' => Controls_Manager::NUMBER, 'default' => '6' ] ); $this->end_controls_section(); } protected function render() { global $wp_query; global $post; extract( shortcode_atts( array( 'posts_per_page' => '6', 'layout' => '2-col' ), $this->get_settings() ) ); if( is_front_page() ) { $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1; } else { $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; } /** * Setup post query */ $query_args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $paged ); $old_query = $wp_query; $old_post = $post; $wp_query = new \WP_Query( $query_args ); get_template_part( 'loop/loop', 'post' ); wp_reset_postdata(); $wp_query = $old_query; $post = $old_post; } protected function content_template() {} public function render_plain_content( $instance = [] ) {} }