I would like to display a popup with some fields from specific page (page preview) when clicking on naviagtion tab. So if I click on navigation item-1 I would like to show fields from Page X, if I click on item 2 I would like to show fields from Page Z. I would like to automate it as much as possible, so I was thinking to create one popup template and use:
get_field( “text_field”, $page );
and use jquery to say if I click on item 1 -> $page = X
etc.
But I am not sure how to add jquery outcome into get_field?
Hi @fanta00
You need to load the fields values first and save it in Javascript variables. It should be something like this:
<script type="text/javascript">
(function($){
$( document ).ready(function() {
var fieldPage_<?php echo $page; ?> = <?php echo get_field( "text_field", $page ); ?>;
});
})(jQuery);
</script>
You can also use AJAX to load the fields. These pages should give you more idea about it: http://api.jquery.com/jquery.ajax/, https://premium.wpmudev.org/blog/using-ajax-with-wordpress/.
I hope this helps.