Display random text from a file with the WP built-in AJAX API April 25, 2022 by Tarik Billa to have the good path to the file, try this : $array = file(plugin_dir_path(__FILE__) . "quotes.txt");