WordPress.org

Forums

Default featured image and for categories? (4 posts)

  1. Nicola
    Member
    Posted 3 years ago #

    Is there a way so have default image for the featured image?

    I already have the featured image/thumbnails showing on blog posts in my theme, but I want the ability to set a default image for the featured image.

    Sometimes I don't always set a featured image so it'd be great if one could automatically be displayed if I didn't set one.

    Is it also possible to set different default images for certain categories?

    (I have tried a few plugins that haven't seemed to work)

  2. Nicola
    Member
    Posted 3 years ago #

    I have researched more and I added `<?php
    //This must be in one loop

    if(has_post_thumbnail()) {
    the_post_thumbnail();
    } else {
    echo '<img src="'.get_bloginfo("template_url").'/images/sr100.png" />';
    }
    ?>
    `
    into my fucntions.php file but it's not working

    Parse error: syntax error, unexpected '<'

  3. Nicola
    Member
    Posted 3 years ago #

    Anyone?

  4. beagledog1
    Member
    Posted 3 years ago #

    I'm afraid It's a standard way but just it work.
    insert codes like below

    if (has_post_thumbnail()) {
    the_post_thumbnail(); }
    <a href="<?php the_permalink(); ?>"><img src="your image path"></a>

    I think Codex would be fixed up anyway

Topic Closed

This topic has been closed to new replies.

About this Topic