start_controls_section( 'section_my_custom', [ 'label' => esc_html__( 'Portfolio Posts', 'brad' ), ] ); $this->add_control( 'posts_per_page', [ 'label' => esc_html__( 'Number of Posts', 'brad' ), 'type' => Controls_Manager::NUMBER, 'default' => '6' ] ); $this->add_control( 'layout', [ 'label' => esc_html__( 'Portfolio Layout', 'brad' ), 'type' => Controls_Manager::SELECT, 'default' => '2-col', 'options' => array_flip( ebor_get_portfolio_layouts() ), ] ); $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() ) ); /** * Setup post query */ $query_args = array( 'post_type' => 'portfolio', 'post_status' => 'publish', 'posts_per_page' => $posts_per_page ); $old_query = $wp_query; $old_post = $post; $wp_query = new \WP_Query( $query_args ); get_template_part( 'loop/loop-portfolio', $layout ); wp_reset_postdata(); $wp_query = $old_query; $post = $old_post; } protected function content_template() {} public function render_plain_content( $instance = [] ) {} }