To call wp-load.php outside wordpress, for example in your case to do some quick ajax stuff, add the following code on the top of your php file.
<?php include($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');?>
But as @fuxia said is better to use the WP AJAX API especially if you create a plugin .
Related Posts:
- When is wp_loaded initiated only with admin or only when user enters the site or both?
- Access bloginfo, get_option, and plugins_url from a non-core php file
- How to get option values without requiring wp-load?
- How can a plugin create a page/form in the front end?
- Looking for WordPress System Diagrams
- How to output message during plugin activation
- How to provide translations for a WordPress TinyMCE plugin?
- Init action hook running late after PayPal’s return url?
- Get specific color from admin color scheme
- Where do I start from
- How do you create a custom edit.php / edit pages page
- Check the Version of an Enqueue’d External Library
- Edit the output of wp_widget_rss_output()
- Change of query var in pre_get_posts not maintained
- Hook for post permalink update
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- How to Parse an Array of Elements in Gutenberg Block
- Load page template with custom content using a plugin
- Custom rewrite rule serves content, but returns 404 error code
- Will changing the ‘Plugin Name’ header in the next update of a plugin break anything?
- Performance of several get_option() calls
- How to edit mySQL wp_posts table from plugin php?
- Creating a Wordpess Plugin that writes data to a csv file. The data doesn’t show in the csv file?
- WP_Query with tax_query, order by most ‘matches’
- Using the Settings API, how should I add multiple values to an option?
- WP custom menus error > menu name already exists?
- Problem with is_active_sidebar?
- Prevent Plugin from loading on ‘wp-admin / wp-login’
- How to sanitize user input?
- Remove Internal Style Sheet if no Value Provided?
- Widget update function not saving values
- Getting admin notices working for plugin errors
- override pluggable.php functions
- An echo line in a transition_post_status action leads to “cannot modify header information – headers already sent by”
- get_the_excerpt() is not returning an empty string when the_excerpt is blank?
- “Plugin could not be activated because it triggered a fatal error.”
- Storing product price data in the database
- Does the order of sections in readme.txt matter?
- Correct check for any admin page with editor
- Add column in WP user but it goes wrong
- modify wordpress default search
- How to remove the current post from the query?
- How to perform a heavy and long process in cron jobs?
- Woocommerce extend tax report with custom column
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- how to get up row in wordpress with wpdb
- Preview plugin store details
- Hook into Jetpacks Publicize without using a post type
- Get attachments from a post
- How to limit number of number of categories displayed by categories widget
- How to remove default style of header in wordpress metabox
- Is it necessary to do validation again when retrieving data from database?
- wp_update_post deletes post meta in CPT
- Using WordPress PHP code, how to bulk delete only 100 subscribers at a time from thousands of users?
- Checking a WordPress for OWASP top 10 vulnerabilities [closed]
- flush rewrite rules after plugin update?
- term_exists() returning NULL on term that exists
- hook filter after the_content on a specific page
- The Correct Way to Use Nonce Field without Settings API
- Run command “composer install” when activating wordpress plugin
- Insert Into Post Not Working For Audio File Using jQuery
- Enqueue a file that’s not js or css
- Adding Custom CSS with PHP
- How to remove/replace current page template?
- How to receive notification of deprecated API elements and functions?
- Using password protection to load different page elements?
- It is possible to pass $args that sent by add_settings_field() inside another function?
- Change reminder email date to 14 days before
- .htaccess with WordPress – create my own pretty url with parameters (above WordPress settings)
- Generating a password-protected front-end page via a plugin
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- wp_remote_post not working with admin-post.php
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Adding Amchart Interface to WordPress API
- WordPress Own Rewrite Rules
- Default media uploader is not showing in wordpress website
- Don’t print customizer styles when no setting has been used
- Load custom translation in custom plugin fails
- Buddy Press restrict the capability to edit users
- Plugin with functions inside a class & how to trigger WP CRON
- “Headers Already Sent” Nightmare on Plugin
- add_settings_error on validating plugin options API
- Uncaught ReferenceError: kpoejy is not defined
- Problem to return more than single line captions
- Unable to show a message after plugin activation
- How to get an array out of a nav menu if it’s a plugin?
- Is there better way to do this without duplicating queries?
- How to create a simple plugin which show/hide an html code in wordpress?
- Can I access WordPress API’s from within plugin scripts?
- Is there a way to make is_search() always return false
- Translation of plugin Upload button
- Ajax url value to pass ‘variable’ to use in query
- Apply Filters Causing a 500 Internal Server Error
- Create wordpress dashboard metabox which spans all columns
- add_filter adds output in the head
- How can i add insertion point between inner blocks in my custom block like core blocks
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Calling get_header() with installed FSE theme
- Reinitiate Gutenburg’s blocks using javascript