Home › Forums › Backend Issues (wp-admin) › Custom Fields Not Appearing
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?
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?
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 for breaking it down for me. Here’s the link: http://www.thepocket.ca/skills_exchange/niki-and-lola-3
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.
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?
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.
I’m not sure what I did, but everything is working now.
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.
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.
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!
The topic ‘Custom Fields Not Appearing’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.