WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] thumbnail images coding problem (6 posts)

  1. Coryan
    Member
    Posted 3 years ago #

    In a couple places on my website (http://festcal.com), the theme is pulling a default thumbnail image instead of the one attached to the post. Here are the two places that it is occurring and the related code. Anyone know how I can get this to pull the correct thumbnail like it does for the other posts on the homepage?

    Bottom of homepage, "Free Events"...here is the code:

    [code moderated as per forum rules - please use the pastebin]

    Archive page, when looking at posts by category...here is the code:

    [dito]

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    instead of the one attached to the post.

    do you mean the 'featured image'?

    if so,
    both codes are not even trying to get the 'featured' image (thumbnail) which is attached to the post.

    the top code asks for a custom field with the key of 'hpbottom' which is supposed to contain the image (thumbnail) url;

    <?php if( get_post_meta($post->ID, "hpbottom", true) ): ?>
    				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "hpbottom", true); ?>" alt="<?php the_title(); ?>" /></a>
    				<?php else: ?>

    the second code does not even have this - it immediately outputs the default image.

    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>

    please confirm where you expect the thumbnail image to come from.

  3. Coryan
    Member
    Posted 3 years ago #

    It is not the featured image that I want. It is the thumbnail that is attached to the post with a custom field (part of the theme functions). If you look at the website, you will see that it works at the top of the home page for two of the sections, but it does not work on the bottom of that page. At the bottom it just pulls the default image...as it does for the category searches that appear on the archives.php page.

    And thanks for your help...this one has me stumped as I'm not a php programmer.

  4. Coryan
    Member
    Posted 3 years ago #

    Alchymyth, I reread your response and it helped me figure out the home page image problem. I've got it working. I changed "hpbottom" to "thumbnail" and it works great. Now I just need to get the other page working. I am trying to figure it out based on what I just learned...but any more assistance would be greatly appreciated.

  5. Coryan
    Member
    Posted 3 years ago #

    OMG...I got it working! Thanks Alchymyth! Your response helped me to see that I needed to add more code to the second code. I had cut and pasted from code on the homepage, but I had not moved the code that called for the custom field. Being that I know almost nothing about php, I didn't realize the additional code was needed...but your response helped me to see that code was missing. THANKS A MILLION!

  6. alchymyth
    Forum Moderator
    Posted 3 years ago #

    edit: well done - you sorted it while i am busy typing here ;-)

    just downloaded the theme -

    the custom field key for the thumbs on the two section on the home page is 'thumbnail'
    while the bottom section looks for the custom field key 'hpbottom'

    if you want to use the same thumbs as in the top sections, change the code in these lines in home.php:

    <?php if( get_post_meta($post->ID, "hpbottom", true) ): ?>
    				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "hpbottom", true); ?>" alt="<?php the_title(); ?>" /></a>

    to something like this:

    <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>

    ----------
    re: archive page:

    can you repost the code (please use the pastebin) ?

    where does this code section come from?

    the problem is - i can't see any default thumbnail images at the bottom of the category archive page.

    can you post a link direct to a category archive page which is showing a default thumbnail image?

    -------------
    edit 2:
    if this is all working now, please mark this thread as resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic