Reputation: 11
Now I have a problem situation with Advanced Custom Field plugin in Wordpress.
Every posts with different information in Advanced Custom Field (ACF), for examples:
-post #1: los angeles
-post #2: texas
-post #3: california
Now, I want to create a custom page named 'Show Locations' template for showing that relevant information when use click on a certain link. How can I track a link that user click on and show relevant data for them.
I've tried:
<?php get_field('field_name', $post->ID); ?>
But it didn't work.
Upvotes: 1
Views: 138
Reputation: 831
To record user interactivity you will need to use javascript and send the data back to the server. PHP is a server-side language so you cannot do it only by using PHP.
E.g
<div data-field-id="1" onClick="sendIdToServer(1)">Texas</div>
You will need to implement a JS method called 'sendIdToServer'
function sendIdToServer(id) {
.. //Read JQuery docs for $.ajax or $.post
}
Upvotes: 1