Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function widget($args, $instance) {
- extract($args);
- $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
- // Variables from the widget settings.
- $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
- //$content_post = get_post($custom_post_id);
- $args = array(
- 'post_status'=>'publish',
- 'post_type'=>'content_block',
- 'p'=>$custom_post_id
- );
- $get_posts = null;
- $get_posts = new WP_Query();
- $get_posts->query($args);
- if ( $get_posts->have_posts() ) : while ( $get_posts->have_posts() ) : $get_posts->the_post();
- echo $before_widget;
- if ( $show_custom_post_title ) {
- echo $before_title . get_the_title() . $after_title; // This is the line that displays the title (only if show title is set)
- }
- echo the_content(); // This is where the actual content of the custom post is being displayed
- echo $after_widget;
- endwhile; endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement