Home › Forums › Front-end Issues › Blank fields
Hello,
WP version: 3.6.1
Settings screen grab attached.
I set up a custom post type called “CV”. I then created some fields and assigned them to the custom post type. These all work perfectly: http://bit.ly/1bZlXrO
Today I opened the CV page template to add a “Download CV” button. So that my client can upload their own CV file, I created a new field group titled “Upload your CV”, selected the field type “File” and assigned it to the CV page template.
After I’d taken these steps, I went to the CV page in WP Admin to upload the PDF. I then added this code on the CV Page template:
<a href="<?php the_field('download_cv'); ?>">Download CV</a>
On the front end, it seems the value is empty. I tried a plain text field type, but it also produced blank results.
Hope you can help!
Thanks
S
Hi @Squideyes
Can you please debug the code like so:
<?php
echo '<pre>';
var_dump( get_field('download_cv') );
echo '</pre>';
die;
?>
What do you get?
Hey Elliot. Thank you for your reply. I’ve received the following output after implementing your code:
bool(false)
Looking forward to your feedback.
S
Hi @Squideyes
Your debugging shows that ACF is unable to load the value. This can be due to 1 or 2 things:
1. ACF has no idea which post to load the custom field from
2. There is no value saved for the current post
Can you explain in which file you are running this code. Is it within the loop? Can you test that the global $post is correct at the time when you run the ACF code?
Thanks
E
Hi @Squideyes
Your code the_field('download_cv');
is outside of the loop! This is why ACF does not understand where to load the data from.
Where is the data for ‘download_cv’ saved? Is it on the page which you have selected the CV template for?
I think the issue is with all your global $wp_query stuff.
You should use not override this global variable, but use a new variable. Also, make sure you use the reset_postdata function after the loop. This is all documented on the WP site.
Thanks
E
You’re awesome!
I need to use a special loop to get pagination working with custom post types.
I used this method: http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-another-page and it worked perfectly.
Thank you for pointing me in the right direction.
WordPress developers would quit without your plugin.
Keep up the good work!
S
The topic ‘Blank fields’ 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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.