Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: How to add a simple default featured image

Discussion in 'Misc WordPress Requests' started by worldless, Feb 23, 2018.

  1. worldless


    Reply To: How to add a simple default featured image, by worldless

    Yea Steve I already tried that plugin (actually it’s the only one) but it’s not compatible enough with one of other plugins I’m using.

    Hello there,

    In your first template-tags.php example, the if is checking for two things. It is asking, are the options set to show images on post archive pages (true === $theme_options[‘post_image_archives’]) AND does this post have a featured image? In your case, you probably don’t want these checks together. You first want to check for the option setting if images should be shown, then, inside there, see if there is an image for a post and, if there isn’t, show a default. Here is how I would do that:

    Hi Scott and thanks for your time.

    Yea those are the options of Napoli theme. they are activated by default and I never changed anything.

    However, it seems you replaced <?php the_post_thumbnail(); ?> with the mentioned code. like I said at the end of the first post I already replaced it and unfortunately it didn’t work !

    I also tried to remove else to see if the default-image.jpg replaces the existing featured images and it did :

    <?php if ( has_post_thumbnail() ) { ?>
    <img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" />
    <?php } ?>

    However the original code won’t replace the non-existent featured images.

    P.S. I also tried WordPress default themes. twentyfifteen and twentysixteen have only one <?php the_post_thumbnail(); ?> I replaced it with that conditional statement and it didn’t work either ! twentyseventeen is a little bit complicated. I replaced them all and the same scenario. could you please confirm that it works at least with one of the default themes ?

    Reply To: How to add a simple default featured image

Share This Page

Monarch Social Sharing Plugin