0

The code below shows the title and content in the modal popup in category.php file. The full tutorial can be seen here although not important: https://artisansweb.net/load-dynamic-content-on-bootstrap-modal-in-wordpress/

jQuery(function($) {
    $('body').on('click', '.view-post', function() {
        var data = {
            'action': 'load_post_by_ajax',
            'id': $(this).data('id'),
            'security': blog.security
        };
        $.post(blog.ajaxurl, data, function(response) {
            response = JSON.parse(response);
            $('#postModal h5#postModalLabel').text(response.title);
            $('#postModal .modal-body').html(response.content);
 
            var postModal = new bootstrap.Modal(document.getElementById('postModal'));
            postModal.show();
        });
    });
});

Having said that, I would like to show the custom-fields in the modal-body too. Currently, custom-fields are shown through this PHP code in single.php. How can I go about doing this?

<?php echo get_post_meta(get_the_ID(), 'Full Name' ,true ); ?>
<?php echo get_post_meta(get_the_ID(), 'Place of Stay' ,true ); ?>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.