• Resolved wpidl

    (@wpidl)


    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;
    }

    return $dfi_id;

    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    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:

    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

    (@wpidl)

    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

    (@janwoostendorp)

    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

    (@wpidl)

    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

    (@janwoostendorp)

    Does the regular Default Featured Image work?
    The one that you can set in the settings.

    Thread Starter wpidl

    (@wpidl)

    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)
  • You must be logged in to reply to this topic.