Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jadportado

    (@jadportado)

    And/or maybe auto hide when there is an image already pulled up by WP?

    Screenshot- https://screencast.com/t/YrV09nOn

    Plugin Author Jan-Willem

    (@janwoostendorp)

    Hi Jad,

    Sorry for the late replay, I was on holiday.

    There are filters which you can use to make exceptions.
    Example:

    function dfi_skip_page ( $dfi_id, $post_id ) {
      if ( $post_id == 23 ) {
        return 0; // invalid id
      }
      return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10 , 2 );

    I suggest you check for the shortcode with has_shortcode.

    Untested example:

    function dfi_skip_gallery ( $dfi_id, $post_id ) {
      $post = get_post($post_id);
      if ( has_shortcode( $post->post_content, 'gallery' ) ) {
        return 0; // invalid id
      }
      return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_skip_gallery', 10 , 2 );

    You second post should be possible to do with the same filter. With different checks.

    Let me know how it went.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable in specific posts – Gallery post’ is closed to new replies.