I want to run wp_query on a separate php file for an ajax call

前端 未结 4 412
难免孤独
难免孤独 2021-01-03 00:43

For example:






        
4条回答
  •  悲哀的现实
    2021-01-03 01:14

    This worked for me, maybe it will help someone else.

    My situation is I have a js file that uses getScript. In that script i have a bunch of .load() calls to a php file. At the top I place this.

    if (file_exists("../../../wp-load.php"))
        {
        require_once("../../../wp-load.php");
        }
    

    Change the ../ to how ever many directories your wp-load file is up.

    Edit - Using WP 3.4.1

提交回复
热议问题