• tymmy456

    (@tymmy456)


    Is there any way I can set a default featured image if it’s not set manually? I’m using WP 3.5.1 and Atahualpa 3.7.7 I’m showing only the excerpts of the post and if it’s set a feature image it will show, I will want to add a default featured image to every post or use the first picture on the post. Thank you for the help, help me and others with their problems ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just downloaded the theme and poked around. If you look at the bfa_post_parts.php which is in the functions folder, you’ll find on line #149:

    if(has_post_thumbnail()): ?>
                    <a href="<?php the_permalink() ?>"> <?php the_post_thumbnail(); ?></a>
    				<?php endif;

    You could change that to have an else as well.

    if( has_post_thumbnail() ) {
     	<a href="<?php the_permalink() ?>"> <?php the_post_thumbnail(); ?></a>
    	} else {?>
    <a href="<?php the_permalink() ?>"> <img src="<?php bloginfo( 'template_directory' );?>/images/default.gif" alt=""></a>
     <?php } ?>

    I would try that and see what happens.

    Thread Starter tymmy456

    (@tymmy456)

    I tried that but I pu the code like this:

    if (function_exists('the_post_thumbnail') AND !function_exists('tfe_get_image')) {
    		     if(has_post_thumbnail()): ?>
                    <a href="<?php the_permalink() ?>"> <?php the_post_thumbnail(); ?></a>
    				<?php endif; ?>
    
    			<p><a href="<?php the_permalink() ?>"> <img src="HERE THE LINK OF THE PIC" alt=""></a></p>
    		 <?php
             }
    		the_excerpt();
    	}
    	echo $after;
    }

    But it puts the picture even if it already has a featured image. Also it shows on the top of the excerpt no of the left side as it would look with the featured image set manually.
    1.How it looks if I put it manually:
    https://prntscr.com/wrxu7
    2. How it looks when I added the code:
    https://prntscr.com/wrxx6
    3. How it looks with setting the featured image manually.
    https://prntscr.com/wry12
    _______________________________________________________
    Thank you for the help and the code, I really appreciate that :).

    ever think about trying a plugin like ‘Auto Post Thumbnail’?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add a default featured image on post’ is closed to new replies.