• 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 Multiple Custom Fields to Posts

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 › General Discussion › Adding Multiple Custom Fields to Posts

This topic is: resolved

Tagged: Custom fields, hooks, plugins

  • This topic has 15 replies, 4 voices, and was last updated 11 years, 10 months ago by Brad Dalton.
Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • June 6, 2013 at 10:49 am #44354
    slydawgg
    Member

    I've created multiple Custom Fields for one of my sites, but am not sure I can locate the best method for making them display on either the Category Page and/or the Single Post.

    I've seen across this forum and other websites to just edit the functions.php file, but if I am not using a child-theme, wouldn't editing the functions.php file within Genesis be a really bad idea?

    Some folks even say just drop your code into Simple Hooks, but I am not 100% that is what would do what I am trying to accomplish; so here is my idea...

    My custom fields are:
    webpage-url
    phone

    I would like the Posts single page to look something like:
    Post Title
    Post Body
    Custom-field "webpage-url"
    Custom-field "phone"

    And if possible the Category Page to be the same as above, but all Posts in the same Category

     

    Has anybody done this successfully, or are people using plugins instead of the Genesis Framework?

    June 6, 2013 at 11:47 am #44368
    Brad Dalton
    Participant

    Published 3 posts on this in the last 2 weeks.

    The Advanced Custom fields plugin is excellent if you want multiple custom fields and meta boxes.

    Nick has also written about this in detail.http://designsbynickthegeek.com/tutorials/how-i-make-custom-fields-easier


    Tutorials for StudioPress Themes.

    June 6, 2013 at 12:03 pm #44375
    slydawgg
    Member

    Thanks for the quick reply.  Unfortunately I was trying to use this plugin earlier and although I created a custom field and gave all of the "Location" information, the custom field still doesn't appear to ever display on the page itself.

    I guess I will keep trying to see if there is something I have missed along the way.

    June 6, 2013 at 12:31 pm #44387
    Brad Dalton
    Participant

    You have to add code to your child themes functions.php file in order for the custom field to work.

    Simply creating a custom field won't work.

    The plugin also enables you to create custom meta boxes in your edit screens.


    Tutorials for StudioPress Themes.

    June 6, 2013 at 1:45 pm #44407
    jon0102
    Member

    I need some help with this as well.

    I've used ACF to create the field, but I can't figure out where to put the php to get it to display on the front-end.

    I created my own child theme from scratch, so there are no existing loops in my functions.php file. Would I need to create a custom loop in order to add my field? Simply adding get_field( "featured_image_description" ); or genesis_get_custom_field("featured_image_description" );  to functions.php doesn't seem to work.

    June 6, 2013 at 2:21 pm #44416
    Brad Dalton
    Participant

    Depends on what you want to do with the custom field.

    Here's an example for images:

    Code not displaying? Grab it on Github.

    You'll need to check out the code examples on the ACF website.


    Tutorials for StudioPress Themes.

    June 6, 2013 at 2:42 pm #44420
    jon0102
    Member

    That's useful, but it's not an image. It's just text.

    I want to be able to add a description to all the featured images on the site. The field would display along with all the other post data (using the Genesis Featured Page widget) and I'd overlay it, sort of like a note on the bottom of a polaroid, using CSS.

    I'm just not familiar enough with php to figure it out, yet. No matter what I add or tweak in function.php myself I just can't get that darned line of text to appear on the front end!

    June 6, 2013 at 7:54 pm #44464
    Brad Dalton
    Participant

    Understand which is why i linked to the ACF code snippets.

    They also offer a forum where you can get the code.

    Once you have the code, the rest is simple.

    You could also remove this line:

    	?><img src="<?php the_field('second_image'); ?>" alt="" /><?php
    endif;
    

    from the code above and change the field name from second_image to your own which should be the same as you use when creating the field using the plugin.

    You can also change the conditional tag and hook in the code above.


    Tutorials for StudioPress Themes.

    June 7, 2013 at 3:16 am #44484
    jon0102
    Member

    ACF seem to be having problems with their website the last couple of days. I couldn't get on the day before yesterday, could briefly yesterday and can't again today.

    The code they give on their website just doesn't work as it should, because they assume you're inserting it at a specific point in your loop, which I don't have the code for in my child theme.

    Would they be able to offer specific examples of how to get this to work in Genesis? Unfortunately the code above isn't doing anything 🙁

    June 7, 2013 at 3:46 am #44487
    Brad Dalton
    Participant

    The code i supplied above works for images only.

    You could try posting on their forum and asking for a custom function.

    Another option is to use another custom fields plugin.


    Tutorials for StudioPress Themes.

    June 7, 2013 at 12:29 pm #44586
    jon0102
    Member

    I'm not sure it's a problem with the plugin itself, but how I'm handling the php side of things. Never mind.

    Thanks for all your help!

    Out of curiosity, where online would you recommend for me to buff up my WordPress PHP knowledge, from very much a beginner's level?

    June 7, 2013 at 12:40 pm #44591
    Brad Dalton
    Participant

    I think its different for everyone.

    You could try sites like:

    http://www.w3schools.com/php/

    http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/

    I think videos are the best

    http://www.lynda.com/PHP-training-tutorials/282-0.html

    http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/


    Tutorials for StudioPress Themes.

    June 7, 2013 at 12:41 pm #44592
    Zach Russell
    Member

    Try the book Professional WordPress Design and Development by Brad Williams! It's a cornerstone read for any WP Developer 🙂


    ———-
    Zach Russell
    President, ProTech Internet Group

    June 7, 2013 at 12:51 pm #44602
    jon0102
    Member

    Brilliant. Thanks guys! 🙂

    August 27, 2013 at 6:40 pm #59141
    slydawgg
    Member

    I meant to follow up on this. I ended up using a combination of Brad's code above, and changing it to better suit my needs. Here is what I ended up using in case it helps others.

    add_action('genesis_post_content', 'title');
    function title() {
    if ( is_single() && genesis_get_custom_field('title') )
    echo '<hr /><div id="postition_title">Title: '. genesis_get_custom_field('title') .'</div>';
    } 
     
    add_action('genesis_post_content', 'phone');
    function phone() {
    if ( is_single() && genesis_get_custom_field('phone') )
    echo '<div id="phone">Phone Number: '. '<a href="tel:' .genesis_get_custom_field('phone') . '">' . genesis_get_custom_field('phone') .'</a></div>';
    } 
    August 27, 2013 at 6:54 pm #59144
    Brad Dalton
    Participant

    Good stuff. Did you use this with the ACF plugin?


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Adding Multiple Custom Fields to Posts’ 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

© 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