• We are using EP Post Widget and our site uses custom post types. This patch (against version 0.2.1) adds an extra option to select which post type to display (similar to the category option).

    --- ep-post-widget_0.2.1.php	2014-01-31 11:16:03.773760700 +0000
    +++ ep-post-widget.php	2014-01-31 11:13:38.510452100 +0000
    @@ -57,6 +57,7 @@
     		//User selected settings
     		$title 			= $instance['title'];
     		$cat 			= $instance['cat'];
    +		$postType 		= $instance['postType'];
     		$showNum 		= $instance['showNum'];
     		$date_format 	= $instance['date_format'];
     		$excerptLength 	= $instance['excerptlength'];
    @@ -68,7 +69,11 @@
    
     		if($title) echo $before_title . __($title) . $after_title;
    
    -		query_posts('cat='.$cat.'&posts_per_page='.$showNum);
    +		$queryParams='cat='.$cat.'&posts_per_page='.$showNum;
    +		if($postType!='') {
    +			$queryParams.="&post_type=$postType";
    +			}
    +		query_posts($queryParams);
     		?>
    
     		<ul class="eppostwidget-list <?php echo $theme; ?>">
    @@ -100,6 +105,7 @@
    
     		$instance['title'] 			= strip_tags($new_instance['title']);
     		$instance['cat'] 			= $new_instance['cat'];
    +		$instance['postType'] 		= $new_instance['postType'];
     		$instance['showNum'] 		= $new_instance['showNum'];
     		$instance['date_format'] 	= $new_instance['date_format'];
     		$instance['excerptlength'] 	= $new_instance['excerptlength'];
    @@ -114,6 +120,7 @@
     		$default = array(
     			'title'			=>'',
     			'cat'			=>'1',
    +			'postType'		=>'',
     			'showNum'		=>'5',
     			'post_option' 	=>'all',
     			'date_format'	=>'Y-m-d H:i:s',
    @@ -139,6 +146,14 @@
     			<br /><em>For multiple categories, separate with comma. An 0 for all categories.</em>
     		</p>
    
    +		<!-- POST TYPE -->
    +		<p>
    +			<label for="<?php echo $this->get_field_id('postType'); ?>"><?php echo __('Post type:'); ?></label>
    +			<br />
    +			<input type="text" id="<?php echo $this->get_field_id('postType'); ?>" name="<?php echo $this->get_field_name('postType'); ?>" value="<?php echo $instance['postType']; ?>" class="widefat" />
    +			<br /><em>Leave blank for default post types.</em>
    +		</p>
    +
     		<!-- SHOW NUM -->
     		<p>
     			<label for="<?php echo $this->get_field_id('showNum'); ?>"><?php echo __('# posts to display:'); ?></label>

    https://www.ads-software.com/plugins/ep-post-widget/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Patch to add support for selecting custom postType’ is closed to new replies.