Advertisement
Guest User

WordPress Custom Posts Plugin: post-widget.php

a guest
Sep 30th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1.  function widget($args, $instance) {
  2.         global $post;       // HKS: Declare global post to ensure external hooks have the right reference
  3.         extract($args);
  4.         $custom_post_id  = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
  5.         // Variables from the widget settings.
  6.         $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
  7.         $post = get_post($custom_post_id);
  8.         $content = $post->post_content;
  9.         $content = apply_filters('the_content', $content);
  10.         echo $before_widget;
  11.         if ( $show_custom_post_title ) {
  12.             echo $before_title . $post->post_title . $after_title; // This is the line that displays the title (only if show title is set)
  13.         }
  14.         echo do_shortcode($content); // This is where the actual content of the custom post is being displayed
  15.         wp_reset_postdata();
  16.         echo $after_widget;
  17.     }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement