How to inject data content from external json into a modal, using UIkit?

Ok. The solution I found out, was more simple than I thought. On the script use “jQuery” instead of “$”. HTML trigger: <a href=”#myModal” onclick=javascript:openModal({{id}})><article>… </article></a> function openModal(id){ jQuery.ajax({ type: “GET”, url: ‘https://www.example.json’ + id, dataType: ‘json’, success: function(data) { var data = data.T.ads; var infoModal = jQuery(‘#myModal’); infoModal.find(‘.uk-modal-title’).html(data[0].brand + ‘ ‘ + data[0].model); htmlData=”<p>” … Read more

Plugin json page

You can hook before the template is loaded and output page content directly: function wpd_output_json_page(){ if( is_page( ‘Page Json’ ) ){ global $post; echo $post->post_content; die; } } add_action( ‘template_redirect’, ‘wpd_output_json_page’ );

How do I use URL to fetch all posts of a particular custom post type?

I think what you mean is do an onclick event. So, you can do this with JavaScript. Create your link as per usual <a id=“myCustomLink” href=“#” onclick=“MyFunction();return false;”>huh! I’m a link!</a> And now some script <script> function MyFunction() { //Make it do whatever here! For example: document.getElementById(“demo”).innerHTML = “Hello World”; } </script> Rerun false; will … Read more

How do I filter Child Posts by Parent Post ID for Custom Post types in WordPress REST API response?

I’d start out by checking that your request is being passed properly. I’d do that by changing this: function custom_api_get_all_posts_callback( $request ) { // Initialize the array that will receive the posts’ data. $posts_data = array(); to this: function custom_api_get_all_posts_callback( $request ) { // Initialize the array that will receive the posts’ data. echo “<pre>”; … Read more