WordPress.org

Ready to get started?Download WordPress

Forums

wp_post_thumbnail ALT and TITLE tags won't work (3 posts)

  1. edzah
    Member
    Posted 3 years ago #

    Hi

    I am having problems overriding the default action of the_post_thumbnail(). I have looked around and everyone says this code will work:

    <?php the_post_thumbnail('thumbnail', array( 'alt' => 'alttext', 'title' => 'titletext' )); ?>

    I get a thumbnail allright but the alt text and title text is from the original image, not 'alttext' and 'titletext' ...

    Has this been changed in WP 3+? I have no idea why this isn't working.

  2. chriseverson
    Member
    Posted 3 years ago #

    It looks like it should be working to me. Do you have any filters running on the_post_thumbnail?

    Refer to the_post_thumbnail in the codex for more details.

  3. edzah
    Member
    Posted 3 years ago #

    Thanks Chris

    The entirety of my theme's functions.php

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '<li>',
            'after_widget' => '</li>',
            'before_title' => '<div>',
            'after_title' => '</div>',
        ));
    if ( function_exists( 'add_theme_support' ) ) {
      add_theme_support( 'post-thumbnails' );
    }
    ?>

    so no add_filter there. Must say I have never used filters before.

Topic Closed

This topic has been closed to new replies.

About this Topic