WordPress.org

Ready to get started?Download WordPress

Forums

featured Image (5 posts)

  1. Lilit_Gr
    Member
    Posted 9 months ago #

    Hi,

    I am trying to add featured image to my posts, but something goes wrong. The image uploads just fine. I can see it in the post managing page, but when I preview the page the image is not there.

    I have added this code - add_theme_support('post-thumbnails'); to the ‘functions.php’ file within my theme folder, but again no result.

    Can anyone help me?

    Thanks

  2. lettergrade
    Member
    Posted 9 months ago #

    What theme are you using? Does your theme have featured image display coded into the template with the_post_thumbnail()?

    Here is a bit of information about the steps involved in making it display: Post Thumbnails

    If you're still having trouble, give us the url of the page you're trying to edit, as well as the section of code in your template that calls the_post_thumbnail().

  3. Lilit_Gr
    Member
    Posted 9 months ago #

    Thanks for your reply lettergrade

    I have enabled the thumbnails for all the posts and the "featured image" metabox is visible on the Edit Post and Edit Page screens. I can upload the images successfully, buy after publishing the images are not visible for the post page.

    I am using 3.5.1 version and here is the site URL http://www.voicebuy.com/

  4. lettergrade
    Member
    Posted 9 months ago #

    Could you paste a section of your code to show us where you are including the_post_thumbnail() in your template file? (i.e. in index.php or single.php)

    (When you post it, make sure to enclose any code in backtick marks with the 'code' button above.)

  5. Lilit_Gr
    Member
    Posted 9 months ago #

    The code is located in the themes functions.php file. And here is the code section.

    function twentyten_setup() {

    // This theme styles the visual editor with editor-style.css to match the theme style.
    add_editor_style();

    // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
    add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

    // This theme uses post thumbnails
    add_theme_support( 'post-thumbnails' );

    // Add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );

    // Make theme available for translation
    // Translations can be filed in the /languages/ directory
    load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );

    $locale = get_locale();
    $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    if ( is_readable( $locale_file ) )
    require_once( $locale_file );

    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
    'primary' => __( 'Primary Navigation', 'twentyten' ),
    ) );

    // This theme allows users to set a custom background
    add_custom_background();

    // Your changeable header business starts here
    if ( ! defined( 'HEADER_TEXTCOLOR' ) )
    define( 'HEADER_TEXTCOLOR', '' );

    // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
    if ( ! defined( 'HEADER_IMAGE' ) )
    define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );

    // The height and width of your custom header. You can hook into the theme's own filters to change these values.
    // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );

    // We'll be using post thumbnails for custom header images on posts and pages.
    // We want them to be 940 pixels wide by 198 pixels tall.
    // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );

    // Don't support text inside the header image.
    if ( ! defined( 'NO_HEADER_TEXT' ) )
    define( 'NO_HEADER_TEXT', true );

    // Add a way for the custom header to be styled in the admin panel that controls
    // custom headers. See twentyten_admin_header_style(), below.
    add_custom_image_header( '', 'twentyten_admin_header_style' );

    // ... and thus ends the changeable header business.

    // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    register_default_headers( array(
    'berries' => array(
    'url' => '%s/images/headers/berries.jpg',
    'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Berries', 'twentyten' )
    ),
    'cherryblossom' => array(
    'url' => '%s/images/headers/cherryblossoms.jpg',
    'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Cherry Blossoms', 'twentyten' )
    ),
    'concave' => array(
    'url' => '%s/images/headers/concave.jpg',
    'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Concave', 'twentyten' )
    ),
    'fern' => array(
    'url' => '%s/images/headers/fern.jpg',
    'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Fern', 'twentyten' )
    ),
    'forestfloor' => array(
    'url' => '%s/images/headers/forestfloor.jpg',
    'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Forest Floor', 'twentyten' )
    ),
    'inkwell' => array(
    'url' => '%s/images/headers/inkwell.jpg',
    'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Inkwell', 'twentyten' )
    ),
    'path' => array(
    'url' => '%s/images/headers/path.jpg',
    'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Path', 'twentyten' )
    ),
    'sunset' => array(
    'url' => '%s/images/headers/sunset.jpg',
    'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
    /* translators: header image description */
    'description' => __( 'Sunset', 'twentyten' )
    )
    ) );
    }

    And I have the following code section in the index.php file:

    <div class="post-entry">
    <?php if (has_post_thumbnail()) { the_post_thumbnail('home-thumb' ,array('class' => 'home-thumb'));}
    else { ?>
    <img class="home-thumb" src="<?php echo catch_first_image() ?>" alt="" width="135px" height="90px" />
    <?php } ?>
    <?php truncate_content('180'); ?>
    </div>

Reply

You must log in to post.

About this Topic