Registered a REST Route but I’m Getting a 400 Bad Request

Make sure you’re reaching the correct endpoint by using rest_url(). When using the REST API and nonces, make sure that the nonce action is set to ‘wp_rest’. add_action(‘enqueue_block_editor_assets’, function () { $data = wp_json_encode(array( ‘restUrl’ => esc_js(rest_url(‘guide-posts/v1’)), ‘nonce’ => esc_js(wp_create_nonce(‘wp_rest’)) )); wp_add_inline_script(‘guide-posts’, “var guidePostsAjax = $data”); }); The permission_callback property is mandatory when registering a … Read more

WordPress send Ajax where click button

@sergio Here is the working answer you can check if there is still any issue paste it here and it if it works well you can upvote the answer to help others. The issue it when you click button your $(this).prop(‘files’)[0] is not working because not this scope to the button element. $(‘body’).on(‘click’, ‘#enviar_fichero’, function() … Read more

How can i add a script with parameters?

Use wp_enqueue_script from your PHP code to register and enqueue a script. WordPress will then handle automatically adding the required script tags at the right place and you’ll be able to instantiate and use the API from your javascript. E.g. (untested, check the docs for your use case) wp_enqueue_script(‘googlemaps’, ‘https://maps.googleapis.com/maps/api/js?&key=KEY’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)