WordPress.org

Support

Support » Plugins and Hacks » Hacks » Setting custom link image as default

Setting custom link image as default

  • How can I set a specific custom link image as default, so I dont need to change every time and write the url that I want.

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can either use this plugin: http://wordpress.org/plugins/default-featured-image/

    Or by replacing image hook in your theme with following code:

    All you really have to do is open the theme file where you are going to display the post thumbnail, this can be (home.php, single.php, loop.php, index.php, archive.php, etc). Then simply paste the following code within the post loop.

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

    Thanks for the fast answer. But I oppened the index.php and inserted the function: (I want to redirect to google per example)

    <?php if ( has_post_thumbnail() ) {
    the_post_thumbnail();
    } else { ?>
    <img src=”http://google.com” />
    <?php } ?>

    But is still not working. What am I doing wrong? Thanks

    The default fallback image will only appear if the post doesn’t have a featured image, otherwise the featured image will appear.

    Make sure you link to a valid image file as http://google.com is not an image file.

    No. I want that my image has an link redirecting to google. I dont want to change every single time to 1-custom link 2-http://www.google.com

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Setting custom link image as default’ is closed to new replies.