Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you should take a look at <a href="https://solislab.com/blog/5-tips-for-using-ajax-in-wordpress/" rel="nofollow noreferrer">https://solislab.com/blog/5-tips-for-using-ajax-in-wordpress/</a> ( old site is down : <a href="http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/#admin-ajax" rel="nofollow noreferrer">http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/#admin-ajax</a> ). </p> <p>By adding a simple function with the right hooks in your <strong>functions.php</strong> you could end up with a nice way of getting exactly what you want.</p> <p>Adapted from the url mentioned above:</p> <pre><code>add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' ); add_action( 'wp_ajax_myajax-submit', 'myajax_submit' ); function myajax_submit() { // get the submitted parameters $postID = $_POST['postID']; $response = get_thumbnail_images(); $response = json_encode($response); // response output header( "Content-Type: application/json" ); echo $response; // IMPORTANT: don't forget to "exit" exit; } </code></pre> <p>I call get_thumnail_images() where I might have a WP_Query or a SQL statement to get the information you need into an array.</p> <p>Let's recap the wordpress part: 1) hooks</p> <p>2) function that get's called based on the action parameter requested by the AjaxRequest (see url for full tutorial)</p> <p>3) a logic function that will give us the thumbnails</p> <p>4) the result is a json enconded array. You can do whatever you want with it on the front end.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload