Title: [Plugin: Category Thumbnail List] Pull thumbnails from Custom Post Type
Last modified: August 20, 2016

---

# [Plugin: Category Thumbnail List] Pull thumbnails from Custom Post Type

 *  [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years ago](https://wordpress.org/support/topic/pull-thumbnails-from-custom-post-type/)
 * Category Thumbnail List lists all thumbnails from default “posts” put in category
   3, but all custom post types with category 3 are left out. Would it be hard to
   modify the plugin to include custom post types as well?
 *     ```
       <?php
       /*
       Plugin Name: Category Thumbnail List
       Plugin URI: http://jonk.pirateboy.net/blog/category/bloggeriet/wordpress/plugins/
       Description: Creates a list of thumbnail images, using the_post_thumbnail() in WordPress 2.9 and up.
       Version: 1.1
       Author: Jonk
       Author URI: http://jonk.pirateboy.net
       */
       $categoryThumbnailList_Order = stripslashes( get_option( 'category-thumbnail-list_order' ) );
       if ($categoryThumbnailList_Order == '') {
       	$categoryThumbnailList_Order = 'date';
       }
       $categoryThumbnailList_OrderType = stripslashes( get_option( 'category-thumbnail-list_ordertype' ) );
       if ($categoryThumbnailList_OrderType == '') {
       	$categoryThumbnailList_OrderType = 'DESC';
       }
   
       $categoryThumbnailList_Path = get_option('siteurl')."/wp-content/plugins/categoy-thumbnail-list/";
   
       define("categoryThumbnailList_REGEXP", "/\[categorythumbnaillist (<a href="http://codex.wordpress.org/:print:">:print:</a>+)\]/");
   
       define("categoryThumbnailList_TARGET", "###CATTHMBLST###");
   
       function categoryThumbnailList_callback($listCatId) {
       	global $post;
       	global $categoryThumbnailList_Order;
       	global $categoryThumbnailList_OrderType;
       	$tmp_post = $post;
       	$myposts = get_posts('numberposts=-1&&category='.$listCatId[1].'&&orderby='.$categoryThumbnailList_OrderType.'&&order='.$categoryThumbnailList_Order);
       	$output = '<div class="categoryThumbnailList">';
       	foreach($myposts as $post) :
       		setup_postdata($post);
       		if ( has_post_thumbnail() ) {
       		$link = get_permalink($post->ID);
       		$thmb = get_the_post_thumbnail($post->ID,'thumbnail');
       		$title = get_the_title();
       		$output .= '<div class="categoryThumbnailList_item">';
       			$output .= '<a href="' .$link . '" title="' .$title . '">' .$thmb . '</a><br/>';
       			$output .= '<a href="' .$link . '" title="' .$title . '">' .$title . '</a>';
       		$output .= '</div>';
       		}
       	endforeach;
       	$output .= '</div>';
       	$output .= '<div class="categoryThumbnailList_clearer"></div>';
       	return ($output);
       	$output = '';
       	$post = $tmp_post;
       	setup_postdata($post);
       }
   
       function categoryThumbnailList($content) {
       	return (preg_replace_callback(categoryThumbnailList_REGEXP, 'categoryThumbnailList_callback', $content));
       }
   
       function categoryThumbnailList_css() {
       	global $categoryThumbnailList_Path;
       	echo "
       <style type=\"text/css\">
       	@import url(\"".$categoryThumbnailList_Path."categoy-thumbnail-list.css\");
       </style>
       ";
       }
       add_action('wp_head', 'categoryThumbnailList_css');
       add_filter('the_content', 'categoryThumbnailList',1);
       ?>
       <?php
       add_action('admin_menu', 'my_plugin_menu');
   
       function my_plugin_menu() {
         add_options_page('Category Thumbnail List Options', 'Category Thumbnail List', 'manage_options', 'category-thumbnail-list', 'my_plugin_options');
       }
   
       function my_plugin_options() {
       	global $categoryThumbnailList_Order;
       	global $categoryThumbnailList_OrderType;
   
       	if( $_POST['save_category-thumbnail-list_settings'] ) {
               // update order type
               if( !$_POST['category-thumbnail-list_ordertype'] )
               {
                   $_POST['category-thumbnail-list_ordertype'] = 'date';
               }
               update_option('category-thumbnail-list_ordertype', $_POST['category-thumbnail-list_ordertype'] );
   
               // update order
               if( !$_POST['category-thumbnail-list_order'] )
               {
                   $_POST['category-thumbnail-list_order'] = 'DESC';
               }
               update_option('category-thumbnail-list_order', $_POST['category-thumbnail-list_order'] );
   
               $categoryThumbnailList_Order = stripslashes( get_option( 'category-thumbnail-list_order' ) );
       	$categoryThumbnailList_OrderType = stripslashes( get_option( 'category-thumbnail-list_ordertype' ) );
   
       	echo "<div id=\"message\" class=\"updated fade\"><p>Your settings are now updated</p></div>\n";
   
       	}
       	?>
         <div class="wrap">
       	<h2>Category Thumbnail List Settings</h2>
       	<form method="post">
       		<table class="form-table">
       			<tr valign="top">
       				<th scope="row">Order by</th>
       				<td>
       					<select name="category-thumbnail-list_ordertype" id="category-thumbnail-list_ordertype">
       							<option <?php if ($categoryThumbnailList_OrderType == 'date') { echo 'selected="selected"'; } ?> value="date">Date</option>
       							<option <?php if ($categoryThumbnailList_OrderType == 'title') { echo 'selected="selected"'; } ?> value="title">Title</option>
       					</select>
       				</td>
       			</tr>
       			<tr valign="top">
       				<th scope="row">Display order</th>
       				<td>
       					<select name="category-thumbnail-list_order" id="category-thumbnail-list_order">
       							<option <?php if ($categoryThumbnailList_Order == 'DESC') { echo 'selected="selected"'; } ?> value="DESC">Descending (z-a/9-1/2010-2001)</option>
       							<option <?php if ($categoryThumbnailList_Order == 'ASC') { echo 'selected="selected"'; } ?> value="ASC">Ascending (a-z/1-9/2001-2010)</option>
       					</select>
       				</td>
       			</tr>
       		</table>
   
       		<div class="submit">
       			<!--<input type="submit" name="reset_category-thumbnail-list_settings" value="<?php _e('Reset') ?>" />-->
       			<input type="submit" name="save_category-thumbnail-list_settings" value="<?php _e('Save Settings') ?>" class="button-primary" />
       		</div>
       		<div>
       			<a href="options-media.php">Update the thumbnail sizes here</a>
       		</div>
       		<div>
       			<a href="plugin-editor.php?file=categoy-thumbnail-list/categoy-thumbnail-list.css&plugin=categoy-thumbnail-list/categoy-thumbnail-list.php">You may need to update your css when changing the thumbnail size</a>
       		</div>
   
       	</form>
         </div>
       <?php
       }
       ?>
       ```
   

The topic ‘[Plugin: Category Thumbnail List] Pull thumbnails from Custom Post Type’
is closed to new replies.

 * ![](https://ps.w.org/categoy-thumbnail-list/assets/icon-256x256.jpg?rev=2437601)
 * [Category Thumbnail List](https://wordpress.org/plugins/categoy-thumbnail-list/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/categoy-thumbnail-list/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/categoy-thumbnail-list/)
 * [Active Topics](https://wordpress.org/support/plugin/categoy-thumbnail-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/categoy-thumbnail-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/categoy-thumbnail-list/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [someguy03](https://wordpress.org/support/users/someguy03/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/pull-thumbnails-from-custom-post-type/)
 * Status: not resolved