Title: Patch to add support for selecting custom postType
Last modified: August 21, 2016

---

# Patch to add support for selecting custom postType

 *  [tfmtfm](https://wordpress.org/support/users/tfmtfm/)
 * (@tfmtfm)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/patch-to-add-support-for-selecting-custom-posttype/)
 * 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>
       ```
   
 * [http://wordpress.org/plugins/ep-post-widget/](http://wordpress.org/plugins/ep-post-widget/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mattias](https://wordpress.org/support/users/darkwhispering/)
 * (@darkwhispering)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/patch-to-add-support-for-selecting-custom-posttype/#post-4562896)
 * Nice!
 * If your interested, do a pull request to the plugin here and I might include 
   it in the next version. [https://bitbucket.org/silentium/ep-post-widget/overview](https://bitbucket.org/silentium/ep-post-widget/overview)

Viewing 1 replies (of 1 total)

The topic ‘Patch to add support for selecting custom postType’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ep-post-widget.svg)
 * [EP Post Widget](https://wordpress.org/plugins/ep-post-widget/)
 * [Support Threads](https://wordpress.org/support/plugin/ep-post-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/ep-post-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ep-post-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ep-post-widget/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mattias](https://wordpress.org/support/users/darkwhispering/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/patch-to-add-support-for-selecting-custom-posttype/#post-4562896)
 * Status: not a support question