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

How to use add_action(‘wp_ajax_[action name]’,…) for a specific page with condition?

As foo is a static function you don’t need to specify the object, so you can use it outside the condition to correctly load it like this : public function __construct(){ if( isset( $_GET[“page”] ) && $_GET[“page”] === ‘edit-foo’ ){ add_action( ‘admin_init’, array($this, ‘init’) ); } add_action(‘wp_ajax_foo’,array( ‘MyPlugin/Classes/MyClassWithFooFunction’, ‘foo’ ) ); } init(){ … <- … Read more

about load more ajax

I made some simple changes to your ajax function call and your ajax-js call.I hope this helps out ajax function call: $return = array(); $paged = $_POST[‘page’]; ob_start(); $args = array( ‘post_type’ => ‘book’, ‘posts_per_page’ => 3, ‘paged’ => $paged, ); $query = new WP_Query($args); while($query->have_posts() ): $query->the_post(); ?> <div class=”ajax”> <?php the_title(); ?> </div> … Read more

Edit user meta on front-end via AJAX

The wp_ajax_ is a prefix for your ajax action. your action is my_tag_count so its should be: add_action( ‘wp_ajax_my_tag_count’, ‘my_action’ ); You tried to access the wrong url in the ajax request because you set wp_localize_script( ‘custom’, ‘my_ajax_obj’, $ajax_url ); So the the request url should be my_ajax_obj its not an object its don’t have … Read more