If it’s a script you created, then move the function outside of WP CLI, where both WP CLI and your PHP script can access, and then have your WP CLI command run that function.
Related Posts:
- Running WP Cron on multisite the right way
- WP-CLI – Selecting PHP version
- WP CLI info showing correct PHP binary but wrong version of PHP
- Utilize WP-CLI from inside WordPress, not SSH
- Setting Up PHPUnit tests for WP development on Windows
- Configuring WP-CLI on Windows 10
- PHPCS: Strings should have translatable content
- Different output from WP-CLI in bash vs PHP exec()
- wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
- PHP Parse error on WP-CLI, not on web server
- WP-CLi PHP Warning: mysqli_query(): (HY000/1356): View During Search Replace
- call to undefined function mysql_connect
- How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?
- Full search and replace isn’t enough to make all pictures to be loaded with https
- Cannot register a custom WP-CLI command
- Running WP-Cron on Multisite networks the right way?
- Transaction when using WP functions rather than vanilla SQL?
- How to run multiple Async HTTP requests in WordPress?
- Can i change wordpress emoji src from http://s.w.org/ to my site?
- WordPress theme & site not loading after moving files
- WP_Query use for a filter with multiple Taxonomies and Terms
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Can I run custom php on specific pages in wordpress?
- Display All Post Attachments and Assign Class to the Last Image?
- Style wp_page_menu() items
- Convert all images to PNG on file upload
- White Screen of Death – wp-admin
- How to update WP about renamed files
- How to sanitize my cookie name
- Custom page archive query by url var calling page twice on one of my custom queries?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Change list item content in menu navigation to add a child element with specific class
- Is it better to create a function or a variable for current_theme_supports?
- Add New User, extra fields which are required?
- Repeating admin-ajax.php not found error in admin
- Remove a div from RSS feed
- how to refresh div on template part?
- Child page menu in sidebar
- Any way to add -1 suffix to the end of every new post?
- Are all hooks/functions tied to Kses meant for sanitization?
- wp_dropdown_pages auto submit
- How to loop through all the attached images in a post, and get their url one by one
- Use Tags to initiate Search
- Noindex Posts From Certain Authors In WordPress
- Pass Variables or Variable Place-Holder from Editor to PHP
- Issue with custom loop in Archive page
- WooCommerce pages looks unstyled
- Get the_content surrounded by instead of
- WordPress forms submissions and PHP files
- Display an image based on field value
- Loading Posts & Category with Ajax
- WordPress call post-ID in jquery
- Enqueueing a code block from an options framework
- List all anchor links on a page
- Assign Custom classes to every Excerpt
- Don’t display a sidebar widget when on a specific page
- Auto create Nextgen Gallery on post creation [closed]
- Hide media for non logged in users
- How to display 8 posts in four columns and 2 rows on a carousel slide?
- How to run php code only for a specific widget on a page and not all widgets on that page?
- excep tonly one css, don’t load any css
- is_front_page is not working in my functions.php
- Is it possible to update the dataset using update_post_meta
- Add Link to PHP message
- Hide payment method based on user role AND minimum cart value
- How to check if plugin update process completed in wordpress?
- Filter for product subcategory listing page load
- Conditional Banners
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- Install functionality for push notifications but WP-Theme has oddly-named, hidden source files [closed]
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- CRON job to update wp_usermeta value each day or week based on server time
- Search function not working
- how to edit open graph meta description programmatically and in which file
- Embedded pages by ID are not respecting Private and Draft status
- What image is this pulling?
- Include a custom field in mysql query
- Adding category in wordpress – custom
- Headers for Contact Form are wrong
- Adding header function to theme
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Display WP posts in 3 responsive columns
- how to register a second page-template
- 2 small questions: How to redirect to a created page & show that pages title in wp, bp
- Posts sortable column not sorting properly for custom field numbers
- Using the wp_remote_post response body
- Use ajax response in PHP function
- Where to put include php file?
- Parse error: syntax error, unexpected token “;” in C:\xampp\htdocs\native\admin\process_login.php on line 19 [closed]
- Load wp_editor on button click
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Replace block content with an array
- How to create custom user role without plugin?
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- WordPress Create New Role Just to Manage Users?
- how to escape alert/window.location.replace with variable
- Inserting more than one array into same row
- How to inject right sidebar on post edit page?
- Filtering with Attributes – how to display all non-queried products below query