Display post thumbnail after clicking on post id with AJAX

You can start by trying this. 1. Change this <span class=”id_53″>Display Post Image</span> to <span class=”id_53″ data-id=”53″>Display Post Image</span> 2. Create you js file $(function () { // click event example $(‘.id_53’).on(‘click’, getThumb); // call the ajax function getThumb() { $.post( ‘http://path/wp-content/themes/your-theme/ajax-file.php’ , ‘my_id=’+$(this).attr(‘data-id’) , showThumb ); } // get image source function showThumb(e) { … Read more

How do I display posts of a specific day?

First things first. Do not you query_posts(). Use WP_Query instead, to prevent messing with the main query. Now, as for your question. WP_Query allows you to enter data parameters too. It even has a date query which you can check it out in the link I’ve provided. Instead of using Admin-AJAX, you can write a … Read more

Class called in template, AJAX not registering

You can’t hook into AJAX in a template, because the template’s not going to be loaded by admin-ajax.php when the request is made. You need to hook into AJAX when the plugin is loaded. Since your hooks are defined in the class constructor (whether nor not this is a good idea is another issue), you … Read more

Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable

Okay, with some great examples from : https://restfulapi.net/resource-naming/ and http://www.restapitutorial.com/lessons/restfulresourcenaming.html I’m going to answer my own question. ESSENTIALLY, for my use case, I will NOT use PUT but rely on POST and DELETE to collection and singleton endpoints. Notes: I’ve omitted the wp-json/my-site-namespace/v1 prepending examples for clarity I’ve used query strings in POST requests but … Read more