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
- 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
- How do I make specific plugin functionality apply to different sites in a network?
- 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
- 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 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
- 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
- Finding posts containing matching array elements in a meta field usign WP_Query
- How to set “Site Address (URL)” programmatically on WP multisite?
- 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
- WordPress Multisite with Azure B2C redirect_urls after Login
- ORDER BY wp_post custom column name in wp_query
- 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
- 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?
- 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 get all the child category name in a specified category name?
- Problem with context in multisite – getting main site data in every blog (get_pages())
- Redirect to another page using contact form 7? [closed]
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- How I can use order by of the custom post title?
- How to query children by post name/slug
- 400 Bad Request, in wordpress theme development, wp_ajax
- Prevent WordPress automatically processing certain URL queries
- WordPress multisite,use same cookies across all website?
- Store custom meta box data as serialized array
- how to load the comment template from a plugin
- How remove trashed WooCommerce orders from wc_get_orders() result?
- Auto-complete or auto-suggest from stored data in database
- add_action wp_ajax_ not loading in plugin file WP Network
- Get post thumbnail in WP_Query
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Pagination not working with custom wp_query
- How to share user data across multiple WordPress websites?
- How to edit wp-signup.php content using plugin
- Adjust query on single
- WP_Query order posts by category
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- Multiple dynamic Tax Query – pass taxonomy argument from array
- How to check category name available or not
- Home page is not loading, where in other pages are displaying on the site
- 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
- 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
- WP Query Relations / Compare
- pull data from wordpress database
- 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
- 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