Support » Plugin: Default featured image » weird action on pages!

  • Muh

    (@m7mad)


    Hey there πŸ˜‰
    It’s a good plugin that worked well on none featured posts images… But!
    When I activate and add the default picture it’s also appeared on all my pages, before the content! why is that?
    By the way, I’m using elementor to build these pages!

    Regards

    • This topic was modified 5 months ago by Muh.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author janw.oostendorp

    (@janwoostendorp)

    Hello Muh,

    DFI works on all post-types by default, so both pages and posts.
    It will always show where the theme will display a featured image.
    If you set a featured image on a page you should see that image on the same place.
    This is done by the theme, not by the DFI-plugin.

    If you want to disable the DFI for all pages you can place the code below in your functions.php or in a seperate plugin.

    function dfi_exclude_posttype ( $dfi_id, $post_id ) {
      $post = get_post($post_id);
      if ( 'page' === $post->post_type ) {
        return 0; // invalid id, so no DFI
      }
      return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_exclude_posttype', 10, 2 );

    Let me know how it goes.
    Jan-Willem

    Thread Starter Muh

    (@m7mad)

    OMG! replying so fast! hhh Thaaaaaank you even if this didn’t work πŸ˜‰

    Well, answering this! there’s no featured image on my pages at all!
    just using The SEO Framework and might the Social Image Settings replaced the featured image! or maybe the Theme as you mentioned which I’m using generatepress!
    Along with the above, All the pages were built with Elementor!

    Anyway, I’ve added this code to the functions.php!
    WORKED! Awesome… just wanted to know how to avoid this without adding a code etc.

    Sincerely
    Moh.

    Plugin Author janw.oostendorp

    (@janwoostendorp)

    Hello Muh,

    Well I’m available. Don’t count on a fast reply always πŸ˜‰

    There is no way to do this without code. That is a deliberate decision when I designed the plugin.

    If you’d like to keep the this out of your functions.php you could create a file like wp-content/plugins/dfi-disable-pages.php

    Add the code in there, and activate the plugin.

    <?php
    /**
     * Plugin Name:       DFI exclude pages
     * Plugin URI:        https://wordpress.org/support/topic/wierd-action-on-pages/
     * Description:       Exclude pages from Default Featured Image
     * Version:           1.0
     */
    
    function dfi_exclude_posttype ( $dfi_id, $post_id ) {
      $post = get_post($post_id);
      if ( 'page' === $post->post_type ) {
        return 0; // invalid id, so no DFI
      }
      return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_exclude_posttype', 10, 2 );
    Thread Starter Muh

    (@m7mad)

    Don’t count on a fast reply always

    hhhh I’m not counting anything :),

    If you’d like to keep the this out of your functions.php

    understand!

    All clear for me…
    Now another thing came out! After inserting the functions.php and the featured image gone from all the pages, I’ve set one page with a featured image! and the problem came back! the future image appeared before the content.
    This is not related to your plugin right?

    Regards

    @janwoostendorp I am running a site on WordPress.com and love your plugin but really need to avoid pages having the default featured image. Any idea on instructions to deploy your fix for my situation – I don’t believe it is easily possible. I’m also not very technical although know most of my way around the admin of WP…

    Plugin Author janw.oostendorp

    (@janwoostendorp)

    Hello Stephen,

    I have no experience with WordPress.com. I didn’t even know my plugin was available there.
    What you want is only available with extra code, like the code above.
    I doubt you can install custom code on WordPress.com I suggest you ask their support.

    If there is anything else I can do let me know.

    Plugins are available to install in the regular way on Business or eCommerce Plans only. I installed your plugin no problem and it works great, I just wish I had a control in settings for it where I could disable the function on pages. That would be super user friendly and might get you more users πŸ˜‰

    Plugin Author janw.oostendorp

    (@janwoostendorp)

    This was a very deliberate choice I made when I developed this plugin years back.
    I wanted this plugin to do 1 thing and do it well.
    Setting it per post-type would have require extra UI that could complicate the plugin.
    And setting per post-type can be done with a little extra code.

    So I never reconsidered it.
    You are the first where this is not an option.
    I’ll think about it but don’t count on it soon.

    I would advise you to hide it on pages with css, the dfi has a specific class to target.

    For now that’s all I can do to help.

    Jan-Willem

    stephenwrks

    (@stephenwrks)

    Hi Jan-Willem, I totally get your point – actually that is what attracted me to the plugin, the simplicity and single-mindedness of it.

    The way I see it, this request of mine is a tweak that would greatly enhance the plugin for non technical users and broaden its user base immensely without really adding extra functionality outside of the main purpose – like this plugin for instance: https://wordpress.org/plugins/auto-post-thumbnail/

    I could do what you suggest using a specific class to target it on pages but that will take too long to figure out and do for every page and so in the end I just give up on this task, as will other non tech users probably, and those on WordPress.com maybe πŸ™

    Any consideration is hugely appreciated πŸ™πŸ˜‰

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.