Support

Account

Home Forums General Issues On click display a popup with fields from page

Helping

On click display a popup with fields from page

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘On click display a popup with fields from page’ is closed to new replies.