Support

Account

Home Forums Backend Issues (wp-admin) Custom Fields Not Appearing

Solved

Custom Fields Not Appearing

  • Hi,

    I’m working on a website for a client – http://www.thepocket.ca and they have a page called Skills Exchange. On this page they would like to be able to post skills/jobs that people in their community offer.

    Here’s what I did to get this going:

    1. I installed the Advanced Custom Fields plugin
    2. I created a Custom Post Type called Skills Exchange
    3. I created a Custom Field called Skills Exchange and entered in all the fields my client wanted in this form (ex. Contact Name, phone number, business)
    4. I published it
    5. I clicked on Skills Exchange on the left side of the page and clicked “Add Skill Exchange”
    6. I filled in all the fields and saved it
    7. I went to my single.php file and added this bit of code to it:

    ‘<?php while ( have_posts() ) : the_post(); ?>

    <h1><?php the_field(‘category’); ?></h1>

    <p><?php the_field(‘business_/_item_name’); ?></p>

    <p><?php the_field(‘contact_name’); ?></p>

    <p><?php the_field(‘phone_number’); ?></p>

    <p><?php the_field(’email’); ?></p>

    <p><?php the_field(‘website’); ?></p>

    <p><?php the_field(‘address’); ?></p>

    <p><?php the_field(‘pocket_resident’); ?></p>

    <?php endwhile; // end of the loop. ?>’

    8. I went back to my Skills Exchange post, saved it again, then clicked “Preview”
    9. Only the title of the post appeared, but all the fields I filled in from the Custom Field I created didn’t show up at all.

    I’m still a bit new to WordPress and php and someone else coded this website before me. Would you be able to point out where I went wrong and what I can do to fix it?

    Thank you!

    • James

    • January 23, 2014 at 7:43 am

    I cant really see what you issue is from that snippet of code.

    Are you getting any PHP errors?
    Can I get a link to the page that is causing the issue?

  • Here’s the link to the page that is just showing the title of my post, but not the fields I filled in from Custom Fields: http://www.thepocket.ca/?post_type=skills_exchange&p=1972&preview=true

    Like I mentioned, I’m still new to php, how can I tell if I’m getting any PHP errors?

    Thanks

    • Elliot

    • January 24, 2014 at 9:43 am

    Hi @emilygutierrez

    The page you have linked to is showing a 404. This means that the page doesn’t exist in the CMS and WP is shopwing the 404.php template (or ‘index.php’ if that doesn’t exist).

    Please edit your post via wp-admin, and click on the ‘view post’ button to get the correct url.

    Thanks
    E

  • Hi @elliot

    Thanks for breaking it down for me. Here’s the link: http://www.thepocket.ca/skills_exchange/niki-and-lola-3

    Thanks,
    Emily

    • MBWD

    • January 25, 2014 at 1:32 am

    @elliot,
    I am having the same problem as @emilygutierrez. I am just using the example page from your site: http://www.advancedcustomfields.com/resources/getting-started/displaying-custom-field-values-in-your-theme/

    and am pretty much getting the same result: just the title with no data.
    I created a Custom Post Type using CPT UI and called it heroimage. I then created a new Custom Field with two entries, custom_title (text) and hero_image (get by URL). I saved the sample page to my theme directory under the title heroimage.php. I entered the data in my custom field and saved it. When I click on View Hero Image, I see only the title, no picture or custom title.

    I have looked into this on various other sites and it seems that the database has to be queried in order to produce results if you are calling them on a page. But your example makes it look like no database query is necessary. I am confused! Please help, because I would really like to master this plugin.

    • Elliot

    • January 26, 2014 at 11:13 am

    Hi @mbwd

    I don’t understand what you mena by I saved the sample page to my theme directory under the title heroimage.php

    I think the issue here is not ACF, but a lack of understanding of the WP templating system. Can you please read up on how WP templates work, and test with simple html code that you can edit the correct template before adding in ACF ‘php’ code?

    Thanks
    E

    • Elliot

    • January 26, 2014 at 11:15 am

    Hi @emilygutierrez

    Can you confirm that the template you are editing is the correct template for the URL you have posted?

    Can you confirm that there are no PHP errors on the page?

    Can you test your code with ONLY a simple text field value.

    Thanks
    E

  • Hi @elliot,

    I’m not sure what I did, but everything is working now.

    Thanks,
    Emily

    • MBWD

    • January 27, 2014 at 6:12 am

    Hi @elliot,
    I did not mean to imply the problem was with ACF. I really am just trying to understand how it works. I’m reading up on the template hierarchy now. Thanks.

    • Elliot

    • January 27, 2014 at 8:43 am

    Hi @mbwd

    No worries, let me know how you go with the template stuff. Your first step should be finding the correct template file in your theme to edit. Just use some simple HTML to test that you are in the correct template.

    Cheers
    E

    • MBWD

    • January 28, 2014 at 7:37 am

    @elliot:
    This is what a noob I am: I didn’t realize you could actually make custom posts appear on ANY page you wanted just by using a query on that page. I thought you had to use one special page to make them show up, and I couldn’t figure out what that mythical one special page was. Now I understand much better how this plugin works, and it blows my mind even more. Thanks for making it!

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.