Your options are:
- Paste the code into a plugin
- Paste the code into a mu-plugin file
- Paste the code into a theme file like
functions.php
I manage this kind of thing with a plugin that builds a simple interface– basically an “execute” button. I alter the code that executes as needed. That seems to give me the most control. The code only executes when I navigate to the right screen and run it intentionally.
Pasting into functions.php
, or similar, and then quickly deleting the code is not a reliable way to run code once. That code will run as many times as your site has visitors before you can delete it again.
You could save an option to the database on first run to prevent a second fire, but that seems like overkill for this kind of “maintenance” code.
Related Posts:
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- How much faster is a tax query than a meta query?
- Use custom posts as taxonomy term meta replacement?
- Is it possible to sort the post based on a custom field?
- List Custom Taxonomy Values according to a Post Meta Value
- Landing in 404 Page on Navigating to Custom Taxonomy Archive
- how to get title to custom tags page
- Getting yoast title for custom taxonomy
- get_the_terms() to show all custom taxonomies
- Single reusable value for post meta: Custom Taxonomy or Post Meta?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- Current category link filter
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- Is it possible to store Json data in post_meta and manipulate
- Add Custom Taxonomy for Blog Meta Info
- How to separate posts in loop?
- Creating terms vs custom post meta to save data?
- Does using custom taxonomy is more CPU efficient than using meta_data?
- Output unique taxonomy terms of posts inside a loop
- Is it safe to register a taxonomy without using any hooks?
- wp_query not resetting, last post hanging
- how to get term id from current post type instead of name
- Count of posts by different parameters?
- WordPress sub taxonomy template
- Sort and paginate custom post taxonomies alphabetically
- WooCommerce custom taxonomy as meta?
- Sort taxonomy page alphabetically by meta rather than default post date
- Convert post meta to custom taxonomy?
- True or F False Setting of ‘with_front’ Parameter of Rewrite Is returning Exact Same result
- Get taxonomy link with post type slug prefix
- Count tags for current post and save into custom meta field (and update it on post edit)
- See double taxonomy inputs in WP editor
- setting a custom post type taxonomy term by code
- transfer two existing taxonomy terms into one custom metabox
- Is it possible to sort the post based on a custom field?
- Dynamic drop down of child terms and then drop down posts
- How to get list of custom taxonomies based on custom post type
- Custom post type term names with ampersand in the term name
- Looking for suggestions on creating simple database (Help!!)
- get meta fields and taxonomy of any post type
- How to make an sql query to exclude everything but custom taxonomy terms in table wp_terms?
- Update fields with post object and custom tax with wp_insert_post
- How can I show custom field according to taxonomy?
- How to associate string with individual use of taxonomy term
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
- How to handle custom taxonomy archive when no posts will have that taxonomy
- How can I list all the meta in a custom taxonomy?
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Copy/clone/associate Custom field to Custom Taxonomy
- Proper WP conditional tag to check for existing taxonomies to list out terms with wp_list_categories?
- Problem with wordpress pagination
- Query posts using custom taxonomy and selected terms
- How to write sql query to get the posts from a custom taxonomy term name
- Foreach loop duplicating a taxonomy thumbnail image
- How to do a particular wp_query taxonomy search
- How to get custom category’s link?
- Edit custom taxonomy description programatically
- How to find taxonomy parent id from child taxonomy page?
- why are the term_id and term_taxonomy_id doesn’t match on custom taxonomies, but are duplicates on categories
- get_the_tags Conditional display of a custom taxonomy
- Removing “trashed” posts from post count in custom taxonomy terms?
- saving meta/custom field to tag
- Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term
- Proper use of wp_get_object_terms
- Remove a href from this code
- Why doesnt this query work? (Custom Taxonomy)
- Permalink Problems
- Get Terms for Page
- Adding a second custom taxonomy to a custom post type (both shown in its table)?
- custom post type, hide or disable the status line in publish meta box
- Take a custom taxonomy value and save as a standard Product Tag
- how to show records that don’t have custom meta value
- Set term on an attachment using wp_set_object_terms and want to display the full term text but it’s showing a slug instead
- Check If Taxonomy A and Taxonomy B has same Slug, 301 Auto Redirect Tax A to Tax B if True in WordPress
- how to get this tax_query working?
- Custom taxonomy archive page requires ?post_type= in url
- Multiple Custom Taxonomy Dropdowns Lists
- Restrict editing of posts with specific taxonomy to users with a matching meta value?
- Why isn’t the ‘no results’ being shown when a query returns no results?
- How to get_the_term_list() from multiple taxonomies?
- Load a certain functions file for a certain taxonomy
- link directly to custom post if there is only one in the taxonomy
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- How to support fifteen thousand terms in WordPress?
- Get taxonomy name for the current post
- Add a term to list in block editor taxonomy sidebar
- Output all terms in a custom taxonomy and add a “active” class only to the ones attached to the current post
- Show Taxonomies with admin area for custom post type?
- How to get posts that contain multiple terms from multiple taxonomies?
- Cannot delete or edit a single term in a custom taxonomy, taxonomy name is wrong?
- View the complete list of a taxonomy in the navigation menu
- How to group all terms children’s in custom taxonomy?
- Reverse order of posts in a certain taxonomy archive?
- My custom taxonomy page is leading in 404 page
- Running a function on post update with new post meta
- Display Posts by Custom Taxonomy Chosen Terms
- Include custom post type custom taxonomies in Categories widget
- Correctly order the hierarchy of custom taxonomy when displaying terms
- Show template part if part of term
- tax_query: Don’t show posts with parent term when they have a corresponding child term applied