Title: Critical error when using custom post type image
Last modified: June 20, 2024

---

# Critical error when using custom post type image

 *  Resolved [wpidl](https://wordpress.org/support/users/wpidl/)
 * (@wpidl)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/)
 * Hi, I’ve edited the code to match my custom post type – listings, but I get critical
   php error every time I try to save the code.
 * add_filter( ‘dfi_thumbnail_id’, ‘dfi_posttype_listings’, 10, 2 );
   function dfi_posttype_listings(
   $dfi_id, $post_id ) {$post = get_post( $post_id );if ( ‘listings’ === $post->
   post_type ) {return 8924; }
 *     ```wp-block-code
       return $dfi_id;
       ```
   
 * }

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

 *  Plugin Author [Jan-Willem](https://wordpress.org/support/users/janwoostendorp/)
 * (@janwoostendorp)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17838586)
 * Hi,
 * The code has the wrong quotes types. I don’t know if this is because an copy-
   paste error.
   But below is the correctly formatted code:
 *     ```wp-block-code
       add_filter( 'dfi_thumbnail_id', 'dfi_posttype_listings', 10, 2 );function dfi_posttype_listings( $dfi_id, $post_id ) {	$post = get_post( $post_id );	if ( 'listings' === $post->post_type ) {		return 8924;	}	return $dfi_id;}
       ```
   
 * And side from wrong quotes this seems like the correct code.
 * Let me know how it goes.
   Jan-Willem
 *  Thread Starter [wpidl](https://wordpress.org/support/users/wpidl/)
 * (@wpidl)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17860615)
 * Hi,
 * I pasted your corrected code, but the image is still not showing for my custom
   post types.
 * It’s like the there’s no image at all to those custom types, but for the other
   posts it’s working fine.
 * Any suggestions?
 *  Plugin Author [Jan-Willem](https://wordpress.org/support/users/janwoostendorp/)
 * (@janwoostendorp)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17862709)
 * Are you sure 8924 is an image ID?
   if not images are showing it is different, 
   so it does something.
 * Does the regular DFI show when you remove this snippet?
 *  Thread Starter [wpidl](https://wordpress.org/support/users/wpidl/)
 * (@wpidl)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17865879)
 * Yes, the number is correct.
 * No, no image shows for custom post type at all if I remove the image snippet.
   
   I’ll try and add manually the featured image to once post and see if it’ll somehow
   change something.
 *  Plugin Author [Jan-Willem](https://wordpress.org/support/users/janwoostendorp/)
 * (@janwoostendorp)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17868156)
 * Does the regular Default Featured Image work?
   The one that you can set in the
   settings.
 *  Thread Starter [wpidl](https://wordpress.org/support/users/wpidl/)
 * (@wpidl)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17895509)
 * Hi,
 * the critical error was not due to the code – figured that out with lots of tests.
 * The featured image shows even without the code for the custom post types – which
   is nice.
   Thank you for looking into it.

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

The topic ‘Critical error when using custom post type image’ is closed to new replies.

 * ![](https://ps.w.org/default-featured-image/assets/icon-256x256.jpg?rev=1058491)
 * [Default Featured Image](https://wordpress.org/plugins/default-featured-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/default-featured-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/default-featured-image/)
 * [Active Topics](https://wordpress.org/support/plugin/default-featured-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/default-featured-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/default-featured-image/reviews/)

## Tags

 * [critical error](https://wordpress.org/support/topic-tag/critical-error/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [feature image](https://wordpress.org/support/topic-tag/feature-image/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 6 replies
 * 2 participants
 * Last reply from: [wpidl](https://wordpress.org/support/users/wpidl/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/critical-error-when-using-custom-post-type-image/#post-17895509)
 * Status: resolved