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

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

For example:






        
4条回答
  •  死守一世寂寞
    2021-01-03 00:56

    You have to include the file that has the Wordpress functions located on the main directory of the Wordpress Installation:

    define('WP_USE_THEMES', false);  
    require_once('../../../wp-load.php');
    

    ../../../ = path to the main directory on your installation

    I found a nice tutorial about this here.

提交回复
热议问题