Hi John. This is what we’re both trying to say. Using the original poster’s example:
This code:
<?php echo the_field('intro_text_shadow_color'); ?>
Should be displaying the value i.e. light_green
However it’s not and I’m having the same issue. It’s displaying the Label and not the value.
How strange. I’ve just been having the exact same issue. From reading the select resource page if you have a value and label it should be the value that’s displayed in the template. i.e. we should only need to add all of the code above if you want to display the label. However the value is not displaying either way.
My search page code is :
<div class="row">
<?php
$loop = new WP_Query( array(
'post_type' => 'events','posts_per_page' => -1, 'order=ASC' )
);
if ($loop->have_posts() ):
while ( $loop->have_posts() ) : $loop->the_post();
get_template_part( 'loop');
endwhile;
else :
get_template_part( 'loop', 'empty' );
endif;?>
</div>
and loop.php
content code is (for example) :
<article id="post-<?php the_ID(); ?>">
<div class="card">
<div class="card-image">
<?php
$image = get_field('event_cover');
if( !empty($image) ): ?>
<img src="<?php echo $image['sizes']['medium'] ?>"/>
<?php endif; ?>
</div>
</div>
</article>
This exact same snippet works for displaying the image of all posts in all pages…but not on search page 🙁
And 302 is the good ID (I mean, the ID of the image that should be displayed…).
Thanks for your time and help John 😉
EDIT: some more details that may help.
1) I have a taxonomy field named “event_style”. When I filter posts by this custom field it works great (The image is displayed correctly). It fails only when I use the distance filter to modify the query…
2) I have another image field displayed (as an object) in the header (so it’s outside the loop). This one doesn’t work neither when posts are filtered by distance. Works well on other pages.
One more follow-up question:
Right now I have a select field with options like “Martin (MN)”. The only reason I have (MN) included is so A) if there were a Martin MN and a Martin WI, these two choices would be different, and B) so the user can tell the difference while selecting counties. However, when displaying the field on my site, I only want to display the name “Martin”, and not “(MN)”. Is the only real solution here some sort of PHP string function, like somehow not displaying the last 5 characters of any county field?
Thanks again.
We just had the same problem with a transition from ACF+Repeater, etc., to Pro. All our field groups but one were duplicated. The one that was not duplicated had only a single text field; each of the others had repeater, WYSIWYG and/or related post link fields.
The bad news is that in at least one case, there are two fields missing from one of the repeater fields in the older version of the field group. The portal_box field in field_group #5209 has only three fields; the one in field_group #5255 contains all five of the fields that should be there. (See attachments.) As a result, part of the portal box is not displaying.
We have no multi-language support. Here’s a list of our active plugins:
ManageWP – Worker (v4.1.6) by ManageWP
Gravity Forms (v1.9.9) by rocketgenius
Admin Quick Jump (v1.4) by James Kemp
Advanced Custom Fields Pro (v5.2.6) by elliot condon
Advanced Post Types Order (v3.6.2) by Nsp Code
BackWPup (v3.1.4) by Inpsyde GmbH
Categories Images (v2.5) by Muhammad Said El Zahlan
Cookies for Comments (v0.5.5) by Donncha O Caoimh
Duplicate Post (v2.6) by Enrico Battocchi
WordPress Editorial Calendar (v3.5) by Colin Vernon, Justin Evans, Joachim Kudish, Mary Vogt, and Zack Grossbart
Enable Media Replace (v3.0.3) by Måns Jonasson
Google Analytics by Yoast (v5.4.2) by Team Yoast
Google Calendar Events (v0.7.2) by Ross Hanney
Gravity Forms – Placeholders add-on (v1.2.1) by Joan Piedra
Gravity Forms MailChimp Add-On (v3.6) by rocketgenius
Image Watermark (v1.5.0) by dFactory
McWebby Magnific Popup (v00.01.00) by Donna McMaster
McWebby Custom Post Types (v00.02.01) by Donna McMaster (declares post types)
Media Tags (v3.2.0.2) by Paul Menard
Members (v0.2.4) by Justin Tadlock
Simple Sitemap (v1.65) by David Gwyer
Sucuri Security – Auditing, Malware Scanner and Hardening (v1.7.9) by Sucuri, INC
Category Order and Taxonomy Terms Order (v1.4.2) by Nsp-Code
ThreeWP Activity Monitor (v2.12) by edward mindreantre
WooCommerce Bulk Discount (v2.3.1) by Rene Puchinger
WooCommerce Dynamic Pricing (v2.9.6) by Lucas Stark
WooCommerce (v2.3.10) by WooThemes
WooThemes Helper (v1.5.5) by WooThemes
WordPress SEO (v2.1.1) by Team Yoast
WP Migrate DB Pro (v1.4.7) by Delicious Brains
WP SEO Humility (v0.1) by Donna McMaster
Must-use Plugins:
ManageWP – Worker Loader (v) by ManageWP
McWebby Debug Log (v0.1.0) by Donna McMaster
I go more specific about my setting.
In my field group, there are 3 sets of field.
First set is select box to switch displaying following sets of field.
So if I chose A for example in the first set, 2nd set of field will be displayed, and if I chose B, 3rd set of field will appear.
In 2nd set, there are one level nested repeater field.
Then I try to add parent level repeater field that’s OK, but when I try to add child level repeater field, all the text input fields have “disabled” attribute in HTML so that I cannot type anything.
Any help or help with some link will be appreciate.
Solved!
By referencing this page: http://www.advancedcustomfields.com/resources/checkbox/
I noticed the code for displaying multiple values on the frontend is:
<?php echo implode(‘, ‘, get_field(‘field_name’)); ?>
So simply by using this but removing the comma it displays the multiple selected values but without adding a comma between each.
<?php echo implode(‘ ‘, get_field(‘field_name’)); ?>
I hope this helps someone else!
Here is the reason you need custom post types–not always, but sometimes.
It’s MUCH easier to display content from custom post types elsewhere on your site (that is, not on the page where you entered the content) than it is to display custom fields elsewhere.
I discovered this the hard way: I set up a repeater field group for “Careers” information. The field names were “job title”, “job description”, and “info link.”
Displaying three sets of these on the original page–no problem. I followed the instructions for looping through repeater fields and it worked fine.
But I wanted to be able to display JUST the custom field content elsewhere on the site. After EXTENSIVE trial and error (I’m not that great a developer), I was able to create a page template that looped through all the posts that had career fields and displayed just the field info.
The problem was that I wanted to sort by job title, not by post, and there were three careers per post. It may be possible to do this with ACF, but according to my Real Developer husband, it would be hugely resource-intensive to do so.
So instead, I created a Career custom post type with ONE custom field (for the info link) and PRESTO! It was extremely easy to create an archive page for Careers that listed careers alphabetically. It was also easy to create a post page template to show 3 career entries with the same taxonomy as the post. AND I can easily display careers in widgets. (It’s a Genesis theme.)
So that’s really why you need custom post types (which may have ACF fields in them): when you have to be able to display the content in different ways in many places in your theme.
For me, at least, rolling a custom post type and taxonomy is a heck of a lot easier than working out ways to display fields, too. WordPress just doesn’t support field retrieval in the same ways as post content retrieval. ACF helps make it easier, but is still limited by the fact that all your ACF data goes into the post_meta table.
I was able to fix this issue using this source:
http://support.advancedcustomfields.com/forums/topic/querying-database-for-repeat-sub-fields-displaying-revisions/
on another note: would it be possible to sort it now by meta_id? so that every added image shows up first in stead of last?
regards!
M
I understand it has to be looped through slb_activate()
but how? It’s not explained anywhere to dummies like me.
I have my gallery displaying using the following code, but the lightbox doesn’t do a thing.
$images = get_sub_field('sc_images');
if( $images ): ?>
<ul>
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
It makes no difference whether I use the_field
or get_field
. I have tried both.
I have no problem displaying the content. Please do not concern yourself with the_content
.
The problem is that what is returned from get_field
(or displayed by the_field
) __includes__ the content.
@hpctech the answer is simple: In your case the ACF is empty, because there is no place so far where you are filling the information that this field should be displaying. The ACF is a “container”, but from where is this container grabbing the information that should be displayed?
Let’s say you use a post to do this. If I am not wrong in your current settings, if you go to Posts > Add new, you will see the new sms2 field you created (below the content editor). Fill that text area with something, a number, whatever, and save it, then in the page where you are using the shortcode write [acf field="sms2"]
or [acf field="sms2" post_id="524"]
and replace 524 for the post-ID from where you want to grab this info.
Hi Elliot,
An old client has reached out to me after foolishly upgrading not only their WordPress install to the latest version (4.1), but also the previous version of ACF (3.?) to 4.4.0. without any regard to compatibility in general. Obviously some things have broken, and I’m trying to determine the quickest way to restore things to a working version. Of course there are no site backups, and from what I can tell, it appears that the previous custom fields I created are missing (not displaying), BUT the field groups themselves ARE still in tact. I’ve read in the forums about database upgrades during the plugin upgrade process and was wondering if that was something I could force to occur as a possible quick solution? As I’m exploring options, I was also wondering if you could provide me with information to download previous versions (3.x etc) to try resolving that way. For whatever reason, I’m unable to find those links on your site.
Many many thanks in advance!
-Eric
Thanks. After turning debug on, I see this in the browser console. I’m not sure I see a connection between what is happening, and what those errors are.
I attached another image showing how the WYSIWYG field is displaying now.
Thanks, that worked for getting the archive to display. I played around with it and got the single employee page to work just fine. However, the overall page that lists all employees, it’s not bad, in that it’s listing the employees one after the other on their own line, single-column. I can click their name to go their single page, and that one seems fine if i just style it (the get_field query is working just fine) but, for the overall employees list page, I’d like its presentation to be two-column, with each employee’s title under their name (title not linked, just their name is linked). I tried this with this syntax:
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php get_field('employee_title'); ?>
The archive page is ignoring the get_field and still just displaying only the permalink. Do you know what’s going on there? I figure if I can get the title to display under an employee name, well then I can style it to be two-column thereafter. I’ve attached the archive file for reference.
Thanks again for your efforts thus far.
EDIT: Also, while I’m waiting for a reply, I’m noticing some of the employees I’m adding here don’t have a URL for LinkedIn. On their single pages, since it’s a template, it’s still generating a hyperlink, but it’s not pointing to anywhere. Is there a syntax I can toss into the single page archive that says something like “if (field) is blank, don’t display this section?”
I looks like when we use $posts = get_field(‘relationship_field’);
and then use foreach ($posts as $post):
This causes issues with the $posts variable. I know i was not able to reset it.
So, i saw this thread on your board.
And i modified my code to match what her solution ended up being:
And now i have this:
<?php
$post_id = 19;
$headerqry = array(
'p' => $post_id,
'post_type' => 'any',
'posts_per_page' => 1,
'status' => 'published'
);
$loop = new WP_Query( $headerqry );
if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
$promo_posts = (array) get_field('header_promo_banner');
if( $promo_posts ): ?>
<?php foreach( $promo_posts as $promo_post): // variable must be called $post (IMPORTANT) ?>
<?php
$attachment_id = get_field('promo_image', $promo_post->ID);
$size = "promo-header";
$image_attributes = wp_get_attachment_image_src( $attachment_id, $size );
if( $image_attributes ) {
?>
<a href="<?php echo the_field('promo_url', $promo_post->ID); ?>" target="_blank"><img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>"></a>
<?php } endforeach; ?>
<?php endif; ?>
<?php endwhile; endif; wp_reset_query(); ?>
And this is letting single.php using standard wordpress loop run. So, I would say that there is definitely a problem with the Relationship field when you use the $posts variable.
Can you please look into this?
Same issue here with some flexible content fields: image, text and true/false. <?php get_sub_field( 'text' ); ?>
is not displaying any value.
Same here, I had some wysiwyg fields named ‘content’ that were not displaying. They were within a flexible content field, I had others that were named ‘content’ as well, and they were showing, in the same flexible content group. Rolled back to 5.1.0 and all is well again.
I’m am noticing this also within a Flexible content field. It looks like select WYSIWYG fields’ content are not displaying when I try to output them to the page:
<?php echo get_sub_field('section_content'); ?>
Hi Navid..Thanks for the suggestion!…I went with ‘Responsive Lightbox by dFactory’ instead, since it was alil easier for me to install on wordpress…
My only issue is I still cant seem to get the lightbox to popup for the Videos…Could it be the way ACF embeds the videos on the page?…
The field type oEmbed is displaying the videos on the page like an actual youtube video player, and not as an image/video thumbnail…so, when I click on the video it just automatically plays from within the player on the page.
Hmm, im abit confused on how to get an oEmbedded video to display in the lightbox…
Is there a specific location in the_sub_field code that I should put rel=”lightbox” for this to work properly?
Also, by chance is there a way that ACF can display the default Youtube Thumbnail image automatically?…if so, that would be helpful.
Appreciate your help with this.
Thanks!
@theatereleven could you post a link to 5.0.7? I brought Pro yesterday so 5.0.8 is the only version I have and it’s not displaying any new field data on the front-end. I’d like to try 5.0.7. Nevermind, I found links to all previous versions under my account page.
No change. It appears that version 5.0.8 isn’t able to return field data. Not just for images but for any field type.
ok. Figured out how to get it all back. When the ACF plugin updated, it lost the addon Repeater Fields, which is how it was displaying all the table fields.
I added them as regular fields, which is why nothing was showing.
I had an old backup of the ACF plugin (v3.1.5) which brought back the addon with all the data 🙂
That is because on the site side, ACF will not apply the conditional logic (only in the admin side). You need to do it by “yourself” using normal PHP condition, just like this:
if (get_field('credentials') == 'expired') the_field('credentials_expired_date');
This way, the credentials expired date
will only be displayed if the credentials
field is set to ‘expired’.
ACF is not applying the condition when displaying the data on the site and it is perfect like this. It is up to you (your code, I mean) to choose if you want or not to display that date (also, the ACF conditional logic doesn’t affect if the ‘credentials_expired_date’ is stored or not, it is only affecting the displaying of the field in the admin area).
Hopefully I have this right, I’m assuming you have these people added on an options page.
A better way to do this would be to have a Custom Post Type for adding the people and then use a relationship type of a field on the page editor where you want to allow them to be selected. If you’re not sure about adding CPTs check out Custom Post Type UI. You can set public to false in the post type so the posts are not accessible from the front end.
Using and options page for your people you’re going to need to build a filter on the acf/load_field hook that gets all the values from the option pages and makes them choices for your checkbox field. I think displaying them on the front end would probably be a bit more complicated than the other way.
When I print_r($object) from the above example, nothing at all is displayed. It’s like the object doesn’t return anything. So the result is:
<pre></pre>
However, I noticed I have another of these loops where get_sub_field_object function appears to beworking, but it’s not in the have rows function.
if (get_sub_field('class_title') ) :
$title_select = (get_sub_field_object('class_title'));
$title_class = get_sub_field('class_title');
$title = ($title_select['choices'][$title_class]);
echo '<h2 class="' . $title_class . ' desktop"><a href="' . $title_class . '">' . $title . '</a></h2>';
echo '<h2 class="' . $title_class . ' mobile">' . $title . '</h2>';
endif;
This is displaying the correct values and labels. print_r(title_select); gives the full array.
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.