How to Use AJAX in a WordPress Shortcode?

后端 未结 5 1381
心在旅途
心在旅途 2020-11-22 08:51

I have a code to display a random quote. One person wrote a function to implement all of this. But the update data via AJAX for some reason does not work. When you press the

5条回答
  •  遥遥无期
    2020-11-22 09:11

    Wordpress shortcode same like function where you give parameters,

    for creating ajax request you can use jQuery.ajax or xmlhttp in your header or function file with add_action wp_head hook.

    you should create ajax.php in your theme folder and on the top of file you should include wp-load.php. and place all your ajax functions in proper manner.

提交回复
热议问题