Title: Custom post type featured image.
Last modified: August 21, 2016

---

# Custom post type featured image.

 *  Resolved [justinledelson](https://wordpress.org/support/users/justinledelson/)
 * (@justinledelson)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/)
 * I am trying to use royalslider to make a slider of featured listings.
 * Within the slider settings I am able to see “property” post type and I am able
   to see many other options such as categories to include, zip codes, cities, etc.
   I selected the category “featured” as I only want featured listings to be included
   in the slider.
 * My problem is that there is no featured image for the posts under the property
   custom post type. So the slider is not getting my listing’s image.
 * [http://mikeaubrey.vividcandi.net/](http://mikeaubrey.vividcandi.net/)
 * You can see the slider is getting the right url and post title but no image
 * [http://wordpress.org/plugins/placester/](http://wordpress.org/plugins/placester/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353360)
 * That site looks great. What have you done to get to this point? Was this created
   using the plugin api or with a shortcode? Both can be used but the answer you
   are looking for will be different depending on which you are using.
 *  Thread Starter [justinledelson](https://wordpress.org/support/users/justinledelson/)
 * (@justinledelson)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353466)
 * The main slider is using royalslider, a very popular slider plugin.
 * I see the custom post type, “properties”. I also see that they don’t have a featured
   image capability. Is there anyway to add that capability.
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353467)
 * Hi Justin,
 * No the custom post type is only there for storing basic metadata information 
   about the listing. Any data associated with a post there will be ignored.
 * Are you creating this using the plugin api or with a shortcode? Depending on 
   what you are doing, you can have the property images come through to your slider.
 *  Thread Starter [justinledelson](https://wordpress.org/support/users/justinledelson/)
 * (@justinledelson)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353468)
 * The slider pulls data from custom post types. Is there anyway to add functionality
   for featured images for the “properties” CPT? Also, where is file that adds the
   CPT? What about the file for the widgets?
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353469)
 * Hi Justin,
 * You should not rely on data attached to the property custom post type. I looked
   at the docs for the slider and there is no requirement to use featured images
   on posts.
 * I can write up an example for you to implement I just need to know if you are
   creating this with the plugin api or with a shortcode.
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353470)
 * Hi Justin,
 * I have contacted the developer of the RoyalSlider to see if I can get a copy 
   of the plugin. When I get this I will be able to write up the code sample (and
   test it). In the mean time, I will try to create something that SHOULD work based
   on the docs.
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353471)
 * Hi Justin,
 * I looked at the RoyalSlider documentation here: [http://dimsemenov.com/plugins/royal-slider/documentation/](http://dimsemenov.com/plugins/royal-slider/documentation/)
   There is a section called Images that suggests you can create a div filled with
   images like this:
 * <div class=”royalSlider rsDefault”>
    <!– simple image –> <img class=”rsImg” src
   =”path-to-image.jpg” alt=”image description” /> </div>
 * To fill up a div like this with the first image from each listing, you can do
   something like this:
 * <div class=’royalSlider rsDefault’>
    <?php $listings = PL_Listing::get(); foreach(
   $listings[listings] as $listing) { echo “<img class=’rsImg’ src='” . $listing[
   images][0][url] . “‘/>”; } ?> </div>
 * be careful about the nested single and double quotes on that line…
 * Now since I don’t yet have access to the plugin, I cannot verify this, but based
   on the docs, this should work.
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353472)
 * Hi Just, this should be the final post on this topic. I got an email from the
   developer today who gave me access to the slider to try out. The code I provided
   works perfectly. I have tweaked it a bit further and included a full PHP page
   in a gist here:
    [https://gist.github.com/technovangelist/9117720](https://gist.github.com/technovangelist/9117720)
 * I’ll be making this into a blog post soon as well. Let us know if you run into
   any other issues.
 *  Thread Starter [justinledelson](https://wordpress.org/support/users/justinledelson/)
 * (@justinledelson)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353476)
 * Hey Matt,
 * Your code works. It grabs the images as requested. Is there anyway to also grab
   the address and possible the published date?
 * Thanks!
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353477)
 * Justin,
 * Great to hear that it works. Try printing out just that $listing object. You 
   will see the full listing data. You should be able to use something like $listing[
   location][address]. Not sure what the field is called for date…but hopefully 
   it will be pretty obvious.
 *  Thread Starter [justinledelson](https://wordpress.org/support/users/justinledelson/)
 * (@justinledelson)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353478)
 *     ```
       <?php
       	$listings = PL_Listing::get(array('limit' => 10));
       		foreach ($listings[listings] as $listing)
       			echo "<img class='rsImg' src='" . $listing[images][0][url] . "'/>".$listing[location][address]."";
       ?>
       ```
   
 * I tried the following it didn’t work.
 *  [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * (@technovangelist)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353479)
 * Hi Justin,
 * Refer back to the docs for Royal Slider ([http://dimsemenov.com/plugins/royal-slider/documentation/](http://dimsemenov.com/plugins/royal-slider/documentation/)).
   Looks like you need to enclose caption text in a div or maybe the image alt tag.
   But just look at the content of $listing. I find the print_r() function useful
   for this type of thing.
 * There is also an updated_at field. It is a Unix time string so you will need 
   to convert it before outputting it to the screen.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Custom post type featured image.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/placester_8d8b8c.svg)
 * [Real Estate Website Builder](https://wordpress.org/plugins/placester/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/placester/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/placester/)
 * [Active Topics](https://wordpress.org/support/plugin/placester/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/placester/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/placester/reviews/)

## Tags

 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)
 * [post-type](https://wordpress.org/support/topic-tag/post-type/)

 * 12 replies
 * 2 participants
 * Last reply from: [Matt Williams – Placester Developer Evangelist](https://wordpress.org/support/users/technovangelist/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/custom-post-type-featured-image/#post-4353479)
 * Status: resolved