Reputation:
In WordPress i'm currently using this function from a plugin <?php the_field('event_boat'); ?>
to output the post ID for the selected field, which happens to be 5755
in this example.
As the plugin only allows me to output the post ID is it possible to incorporate the value from that function inside <?php echo get_permalink(); ?>
to get the permalink based on the post ID?
Upvotes: 0
Views: 106
Reputation: 11
This should work fine. :)
<?php $a = get_permalink(get_field('event_boat')); echo $a; ?>
Upvotes: 1
Reputation: 703
This should work fine. :)
<?php echo get_permalink(get_field('event_boat')); ?>
Upvotes: 0
Reputation: 2263
You can pass the ID as a parameter in the get_permalink function, either by storing the ID value in a new variable, or just passing in the ACF-function directly as a parameter.
$post_id = get_field('event_boat');
echo get_permalink($post_id) // echoes out link for ID 5755
I'm using get_field() instead of the_field() because the_field() will echo out the value, We just want to pass it along. We might aswell just do:
echo get_permalink(get_field('event_boat'));
Upvotes: 1