'widget_custom_post_widget', 'description' => __( 'Displays custom post content in a widget', 'custom-post-widget' ) ); parent::__construct( 'custom_post_widget', __( 'Content Block', 'custom-post-widget' ), $widget_ops ); } function form( $instance ) { $custom_post_id = ''; // Initialize the variable if (isset($instance['custom_post_id'])) { $custom_post_id = esc_attr($instance['custom_post_id']); }; $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : true; $show_featured_image = isset( $instance['show_featured_image'] ) ? $instance['show_featured_image'] : true; $apply_content_filters = isset( $instance['apply_content_filters'] ) ? $instance['apply_content_filters'] : true; ?>

' . __( 'Edit Content Block', 'custom-post-widget' ) . '' ; ?>

id="get_field_id( 'show_custom_post_title' ); ?>" name="get_field_name( 'show_custom_post_title' ); ?>" />

id="get_field_id( 'show_featured_image' ); ?>" name="get_field_name( 'show_featured_image' ); ?>" />

id="get_field_id( 'apply_content_filters' ); ?>" name="get_field_name( 'apply_content_filters' ); ?>" />

post_content; if ( $post_status == 'publish' ) { // Display custom widget frontend if ( $located = locate_template( 'custom-post-widget.php' ) ) { require $located; return; } if ( !$apply_content_filters ) { // Don't apply the content filter if checkbox selected $content = apply_filters( 'the_content', $content); } echo $before_widget; if ( $show_custom_post_title ) { echo $before_title . apply_filters( 'widget_title',$content_post->post_title) . $after_title; // This is the line that displays the title (only if show title is set) } if ( $show_featured_image ) { echo get_the_post_thumbnail( $content_post -> ID ); } echo do_shortcode( $content ); // This is where the actual content of the custom post is being displayed echo $after_widget; } } }