• 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

Image Function Using Custom Field Name NOT Number in Array

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 › Image Function Using Custom Field Name NOT Number in Array

This topic is: not resolved

Tagged: custom field, genesis_get_image, images

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 10 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 3, 2014 at 8:27 am #112857
    kimmiemcc
    Member

    This a question regarding Genesis functions to add images to a post (custom post type to be exact). I'm uploading images to a custom post type using Advanced Custom Fields. I found this great Genesis image tutorial http://designsbynickthegeek.com/tutorials/genesis-explained-image-functions but I still have a question. Is there a way for me to pull images by custom field name instead of the order in which they were attached to the post (see the 1 in the array below, which is attaching the first uploaded image other than the featured image)?

    The code below belongs to a custom post type which the site owner will use to add a few images via the WordPress editor. The problem is that he may not upload the images in the order that the fields appear in wp-admin, so he could get unexpected results that way. If I could replace the 1 in the array (or 2 or 3 for the additional images) with the custom field name (i.e. award_1, award_2, award_3) then there will be no chance of the wrong image displaying.

    Also, the number in the array is displaying images which remain attached to the post in the media library even though they may have been deleted via wp-admin after upload. They are still counted in the order in which they were uploaded to the post if someone doesn't take the trip to the media library to delete them there, too. (I get this, owner won't.)

    Here is the code for displaying the first image attached:

    function rating_award_1() {
    if ( is_singular('profile') && genesis_get_custom_field('rating_award_1') )
    echo '<div id="rating-award-1"><h4>Recognition</h4> '. genesis_get_image( array(
    'size' => 'full',
    'num' => 1,
    'attr' => array (
    'class' => 'alignmiddle'
    ) ) ) .'</div>';
    }

    http://acl.buzzflymedia.com/attorneys/john-castro/
    August 6, 2014 at 6:47 am #117323
    Susan
    Moderator

    As you posted this over a month ago, I hope your issue was resolved. If not, check back in, and I will escalate.

    Thanks!

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 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