Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #434729

    Is there a way to make “Don’t display image on single post” checked by default? I use a plugin that automatically creates posts and do not want the featured image on them.

    #435137

    Hey DJQuad!

    Thank you for coming back.

    If you are using a child theme in functions.php of the child theme put the following:

    
    /* 
    Add a checkbox to the featured image metabox 
    */
    if(!function_exists('avia_theme_featured_image_meta'))
    {
    	add_filter( 'admin_post_thumbnail_html', 'avia_theme_featured_image_meta');
    	
    	function avia_theme_featured_image_meta( $content ) 
    	{
    		global $post, $post_type;
    	
    		if($post_type == "post")
    		{
    		    $text = __( "Don't display image on single post", 'avia_framework' );
    		    $id = '_avia_hide_featured_image';
    		    $value = esc_attr( get_post_meta( $post->ID, $id, true ) );
    //		    $selected = !empty($value) ? "checked='checked'" : "";
    			$selected =  "checked='checked'";
    		    
    		    $label = '</div><div class="av-meta-extra-inside"><label for="' . $id . '" class="selectit"><input '.$selected.' name="' . $id . '" type="checkbox" id="' . $id . '" value="1" > ' . $text .'</label>';
    		    return $content .= $label;
    		}
    		
    		return $content;
    	}
    }
    
    

    Otherwise modify enfold\functions-enfold.php line 1188: locate

    
                $selected = !empty($value) ? "checked='checked'" : "";
    

    and replace with:

    
    //		    $selected = !empty($value) ? "checked='checked'" : "";
    			$selected =  "checked='checked'";
    

    Regards,
    Günter

    #435405

    Thanks. Will this also make it not display the featured image on posts created outside of that form?

    #435870

    Hi!

    What do you mean by “posts created outside of that form”? The code above should enable the Don’t display image on single post option by default.

    Regards,
    Ismael

    #436099

    Like I said in my OP, a plugin creates some of the posts. I also post via Email.

    #436825

    Hey!

    Please give us a link an example of the post. Maybe, we can use css to hide it.

    Cheers!
    Ismael

    #436885
    This reply has been marked as private.
    #437986

    Hi!

    Please add following code to Quick CSS in Enfold theme options under General Styling tab

    .single .big-preview.single-big {
      display: none !important;
    }

    Cheers!
    Yigit

    #438170

    That won’t work because some posts do have featured images. I’d just like them to be not showed by default, unless I edit the post and uncheck the option.

    #438945

    Hi!

    I’m not sure how this plugin creates the post. You can’t access those posts in the Posts panel?

    Cheers!
    Ismael

    #439064

    Yes. Regardless whether I use the plugin or not (I may end up not), it would still be an issue with posting via Email. I’d like the image to automatically not be displayed by default. If I want it to be displayed I can edit the post later.

    #440127

    Hey!

    Alright. What do you mean by “posting via Email”? You’re trying to make a simple thing complicated or trying to fully automate the settings. If you don’t want a featured image on a post then don’t add a featured image. If you do want a featured image but don’t want to display it in a single post then tick the option under the featured image box. Aside from that, I don’t think we can help with the plugin nor the email settings. Please contact a developer to configure those settings.

    Regards,
    Ismael

    #688240

    // $selected = !empty($value) ? “checked=’checked'” : “”;
    $selected = “checked=’checked'”;

    It’s works. thanks
    這個程式碼可以使用,謝謝

    • This reply was modified 7 years, 7 months ago by Moaaaaya.
    #688939

    Hi @Moaaaaya,

    Great, glad it’s working for you and thanks for the feedback :-)

    Best regards,
    Rikard

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Don't display image on single post’ is closed to new replies.