You can add the following snippet at the start of your PHP file to load WordPress in it.
define( 'WP_USE_THEMES', false );
require('wp-blog-header.php'); // chage the path to match your WP directory
//the rest of your code here
EDIT:
Alternatively, you could use wp-load.php
instead of wp-blog-header.php
.
define( 'WP_USE_THEMES', false );
require('wp-load.php'); // chage the path to match your WP directory
//the rest of your code here
This answer explains that:
It loads all of WordPress, but doesn’t call wp() or invoke the
template loader (used by themes). Method 2 will be a little
lighter-weight, but should give you the same functionality.
Related Posts:
- How do I create a custom role capability?
- WP_Query leaking absurd amounts of memory
- Prevent network activation of plugin
- Uninstall script for a plugin in Multisite
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Changing Plugin Load Order
- What is wrong with using add_option with Multisite instead of add_blog_option in a plugin
- Register custom query args parameter for WP_Query()
- How to add multiple custom URL variables?
- Getting wrong relationship value in $args in wp_Query?
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Check for featured image in WP_Query
- Why Does get_posts() Return an Empty Set?
- Cron firing my function everytime wp-admin is visited
- Error getting correct blog_id on MU from functions.php
- How do I make specific plugin functionality apply to different sites in a network?
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- How to ensure “the_content” filter runs only for the main displayed content?
- add_filter and remove_filter added before and after wp_query
- WordPress multisite apply different options over each site from same plugin
- How to get all images and their thumbnails from wp media library
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- How to create a dynamic page based on form data with a plugin?
- Multisite, sharing content by URL
- Only allow plugin to be activated on root site of multisite
- How to use wp_set_password in a plugin?
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- WordPress Media mime type filter problem 4.0
- Handling form request from plugin file
- What is the best way to overwrite /wp-admin/ms-delete-site.php
- Where should I store global data for my multi-site WordPress plugin?
- unable to stop loop when using wp_insert_post with publish_post hook
- Customize multisite site creation with user data
- Multisite plugin development and wp_enqueue_script
- Plugin Uninstall and Deactivate via Options Menu
- how to activate plugin network-wide, and save setting across sites
- Cannot search post by taxonomy
- How to get orders with used coupon in WooCommerce
- WP_Query with tax_query, order by most ‘matches’
- Sharing a common set of image files for media library, across all sites within multisite
- What is difference between blog id and site id?
- How to create a Tools menu on the Network Admin dashboard from a plugin
- How to print raw query from WP_Query class just like in CodeIgniter
- WP_Query returns no results
- Finding posts containing matching array elements in a meta field usign WP_Query
- Create a custom display order in the main menu
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- How to set “Site Address (URL)” programmatically on WP multisite?
- manage_posts_custom_column, showing serial number using increment in loop
- Error : “Cannot use object of type WP_Post as array in”
- Proper way to run wp_query from inside a plugin
- using new WP_Query in save_post function alters $post
- How to associate an existing user to a site in a multisite setup programmatically
- Slow WP_query due to nested wp_query. Need Suggestions
- WordPress Multisite with Azure B2C redirect_urls after Login
- ORDER BY wp_post custom column name in wp_query
- How To Change Post Author Default?
- How to create database table, add data, update and delete using wpdb via plugins?
- Adding (blog-specific) links to “My Sites” admin page
- Plugin menu addition in multisite
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- WP_Query filters
- How to fetch only current hour posts?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Multiple Plugin best practice in Multisite
- WordPress pre_get_posts with combined results of two queries (OR)
- Search: how to extend the existing search to include a custom table
- how to create a shortcode from a variable in plugin
- How do I ensure I can loop through every enqueued script and CSS?
- User meta query using Wildcard
- Group By in a Metaquery
- WP Query date_query with several date range
- Custom Plugin activation error in Multisite
- Replace “content-area” of themes 404 page with plugin?
- Multisite and the JSON REST API: How to?
- Testing Plugins for Multisite
- Making Woocommerce optimized for more than 500k products
- Post Pagination does not working on WP-Query
- WP Query Relations / Compare
- pull data from wordpress database
- How can I query 3 posts from diferente categories (one of each category)
- Query only title/field/featured media of posts [closed]
- Same header/footer in Admin, across all network sites in multisite
- Custom MySQL query to pull out Advanced Custom Fields?
- post_results filter confused by pagination in sidebar and main section
- Can’t get query string in ajax call
- Get custom wp_query search results to appear on search.php
- Change Admin menu placement using hooks
- loop and in admin header problem
- How do I query posts and have their related taxonomies returned in the results?
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- Force remove parent theme CSS/JS and call them from Child theme
- $_GET vs get_query_var()
- What is the meta_query key name for the woo product average rating? [closed]
- get the queried_object of an url
- Return custom product in ajax call loop
- filter on get_posts efficiently
- 2 Domains pointing to SIngle WordPress , issues with links