You could use a WordPress action hook. For example, you could add the following code to your themes functions.php file:
add_action( 'init', 'your_script_function' );
function your_script_function() {
// your script here
}
The first line makes WordPress execute the ‘your_script_function’ function on initialization. You can add your script in that function.
Alternatively, you could add the code to a plugin. This would be easier for using/installing the script on multiple WordPress installations. It is indeed not recommended to edit the WordPress core files.
For more information about WordPress actions and hooks:
Related Posts:
- How to check if image is already stored in a site’s post database? (network)
- How To Make Connection To WordPress Data Base In A Plugin?
- Changing user_nicename
- WordPress will not operate correctly
- How to Join two tables from separate databases within WordPress
- Refresh page after update_post_meta
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- How to track a users progress through pages by inserting data into WordPress Database?
- Import 10,000 Users into WordPress WITH a specific ID for each user
- WP database error for comments_popup_link()
- if statement on database query
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- How to create Sub Sub domain Multi User blogs?
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- How to generate page content from database the right way?
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- phpMyAdmin displays error when importing database
- Prevent Data Resubmission On Page refresh
- SQL QUERY – Select a value directly from the database
- How to get the POST TITLE using the POST ID?
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- Any possible way to make $wpdb->get_results() return anything else than array?
- WordPress Scheduled Event Request Blocking
- Transferring working local PHP site to wordpress – with database (MySQL)
- Trying to establish connection to External Database
- Getting id of poll from WP database
- How to insert a single row to WP database table?
- $wpdb->update with multiple parameters gives error
- wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
- How does WordPress know wich language is chosen when there is a database connection error
- How can I save unique user data on my site? [closed]
- Is it possible to create a wordpress database with php code?
- Store a default value for a transient on plugin activation
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- Dynamic content in template
- inserting a post from an extern php file but post content doesn’t show on wp site
- Databases – Submitting data from inputs to database [closed]
- db converts decimal number wrong
- Filtering a Database Query
- Is it best to avoid using $wpdb for security issues?
- Blob file download problem
- How to retrieve the data from the sever and displaying it in a page?
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- Creating Database Table vs. Adding MetaData to Post & User
- How can I find the cause of a 500 server error?
- I can’t update my data through $wpdb
- Can’t successfully check if post with title exist in database
- Cant connect to database with php 7.3
- Delete database record using plugin from admin panel
- How to get image from url from the database?
- Wpdb get->results to out the the month from the db
- Filter results from a serialized string to use on statistics
- How to add data to a custom field at the wp_users table?
- Creating custom page template from existing PHP site
- wordpress site – using custom database and PHP
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Add row to custom database Table and delete all rows older than 1 day
- Database entry removed on browser refresh, Ajax PHP jQuery
- Please help! I have a problem with getting wordpress databas
- Change wordpress’ database data using ajax – how to get current user id?
- Error establishing a database connection (Set-up locally)
- add role on WordPress in PHP on a second database
- Create a new account on site B with data from the purchase of site A
- How to search order using database frontend short code WordPress
- Limiting posts based on nested meta_query
- Preserving backslashes in post_content
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Error establishing a database connection (configuration)
- Unable to insert two value in two different columns (WordPress database)
- Retrieving and Displaying Data From a Table
- why not selecting multiple rows of same standard_id using SQL query from database?
- Using custom php to connect to database blocks wp from accessing galery pictures
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- Updating the database after parsing CSV document
- getting the values of hidden inputs to use them in a php mysql query
- How do I fetch a data from an external database into my wordpress homepage
- How to display post_content from database in different on template page?
- Front end/Database connection in WP
- Issue in url update when using wordpress update query
- can’t delete a row from post_meta table
- special characters not supporting in wordpress
- How to set max users to 17.000
- How to fetch results from database
- Unserializeing multiple column values that are stored in one database results variable
- Best way to define a database with product codes and back-end support?
- How to connect database table to each registered wordpress user.
- Querying multiple meta_keys in WordPress SQL query
- Let users register weight each day and save it in DB
- Query specific posts per user selections from dropdown menus
- Create an unique ID number after submit form
- Fetching wpdb data from a php file seems to break?
- save array of objects with update_option
- Execute multiple PHP Snippets causes error?
- Can’t insert into a database wordpress
- Updates applied to staging WordPress site affecting production even with different databases