• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Adding link to custom field image

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding link to custom field image

This topic is: resolved

Tagged: Custom fields

  • This topic has 3 replies, 2 voices, and was last updated 11 years, 4 months ago by TGScreative.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 16, 2014 at 2:08 pm #128045
    TGScreative
    Member

    I am working with a theme with custom post types with custom fields. One of the custom field points to an image. I want to place the image as a thumbnail on the category page and link to the post. Maybe I made a small error in the PHP and that is why the link is not working? This is the code I placed in the functions.php file:

    //* Add custom field thumbnails to artwork categories
    add_action( 'genesis_before_entry', 'category_thumbnail' );
    function category_thumbnail() {
    if ( is_archive()   ) :
    echo '<a href="index.php?p='. the_ID() .'"><div class="thumbnail" style="background-image: url('. genesis_get_custom_field('artwork_image') .');"></div></a>';
    
    endif;
    }

    I used the image as a background-image because it gave me more control over how it was cropped. The thumbnail looks fine it just isn't linked. Any ideas what I may have done wrong?

    http://artbaseweb.artbase.com/artwork-category/painting/
    October 17, 2014 at 12:45 am #128088
    Brad Dalton
    Participant

    Here's one way http://wpsites.net/web-design/how-to-add-a-2nd-meta-box-for-a-different-featured-image/

    Or this http://wpsites.net/web-design/add-unique-header-images-using-custom-fields/


    Tutorials for StudioPress Themes.

    October 17, 2014 at 8:34 am #128144
    TGScreative
    Member

    Brad, my question was not how to place an image from custom fields. That I have done. My question was how to get the image to link back to the post it was featured on. Would you have any source for how to do that? Thank you for your help.

    October 17, 2014 at 8:48 am #128145
    TGScreative
    Member

    Figured it out! Simple mistake. Instead of the_ID() should have used get_the_ID()

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Adding link to custom field image’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble