I’m in a foreach loop and trying to get the custom fields.
I’ve tried
$link = get_field("external_link",$post->ID);
echo $link;
but it doesn’t work, but if I try
$link = get_post_meta( $post->ID, 'external_link', true );
echo $link;
it works, can’t figure it out.
Hi @haleeben
Have you debugged $post->ID and $link?
As in, have you printed out the contents of these variables?
<?php
echo '<pre>';
print_r($post->ID);
echo '</pre>';
die; ?>
Hey @elliot
Yeah
$post->ID = the right post ID (1682)
$link = get_post_meta( $post->ID, 'external_link', true );
gives me the string I need ‘this is the link’
but
$link = get_field("external_link",$post->ID); = nothing,
if I do a var_dump of $link it shows bool(false)
if get_post_meta works, shouldn’t get_field work?
Hi @haleeben
100% yes. The get_field function should be working for you, I don’ understand why it isn’t..
Do you have any filters which could be hooking in and overriding the value returned?
Any chance you would debug the issue through the core/api.php file? (the get_field function is within that file)
Hey @elliot
The latest update for ACF fixed this issue, sorry I should have mentioned I was trying to do this from the functions file, thanks for the update.
PS – is this a custom built support forum theme, is it available to buy? one of the best I’ve used.
Hi @haleeben
its a bbPress support forum with a custom theme and custom functionality!
Thanks mate
Elliot