You can loop through each of the $posts
and update the post_content with update_post_meta
.
<?php
foreach( $posts as $p ) {
update_post_meta( $p->ID, 'post_content', 'YOURCUSTOMEDITS' );
}
?>
edit: if you want to use wp_update_post, it’d look like this:
<?php
foreach( $posts as $p ) {
$my_post = array(
'ID' => $p->ID,
'post_content' => 'New text',
);
// Update the post into the database
wp_update_post( $my_post );
}
?>
Related Posts:
- count() parameter must be an array or an object that implements countable in laravel
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)
- Receiving Stripe Webhooks on a wordpress website
- Sorting list of sites from multisite network using wp_get_sites
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- PHP XMLRPC for WordPress: Adding meta tags and description
- How do I get the author’s page url from their ID?
- probleme adding Txt and Links in preg_match()
- Correct use of curly braces vs alternative synax
- the_author_meta not working
- Missing Author Information
- How can I set custom order use this function
- Configuring WP-CLI on Windows 10
- Assign a picture URL to a page via PHP
- Check if Product is in a Specific Category in Functions.php
- How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1
- Adding ads code between comments
- How to send user data in json format to another server when user register on wordpress site in PHP
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Limiting woocommerce line_total decimal length
- Fetch posts from category in custom page template
- How do you use WP slugs for PDF files / media?
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- only show container with next/prev links if they exist?
- JS file work only in index page
- If no products are on sale – hide ID or class
- Custom shortcode outputs plain text instead of HTML at top of post
- How to get the value of input hidden html from text editor to custom page template?
- Gravity form built in Captcha
- Autocomplete search box
- Fetching instagram api not working on wordpress
- add_theme_page to add_menu_page theme options convert
- WordPress Scripts Being Loaded in Footer
- Jquery function working in Dev Console but not otherwise [duplicate]
- Headers already sent in Pluggable.php / homepage and wp-login error
- Unique session WordPress
- Get posts from multiple post type
- How to convert select to HTML with PHP tags inside of it [closed]
- get the correct url for an folder in wp-includes wordpress
- Can i put my shortcode inside a variable in php files?
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- JS value to PHP variable to change div background color with PHP If else statement
- How to fix “Object of class WP_Term could not be converted to string”?
- Started getting warning message following host’s PHP upgrade
- Store post content in a php variable and output them using for loop
- Running rmdir function on post save
- Only show image from custom field when present
- Upload multiple files in randomly generated folder using wp_upload_bits
- Loading two post layouts for the same post with different url
- How do I populate custom field with current user role in Woocommerce [closed]
- Parse error: syntax error, unexpected ‘}’ [closed]
- Personalize checkout text
- When echo follow Ajax button inside Ajax pagination template not working?
- jQuery Ajax PHP function call returning [object Object]
- Add category to post meta
- Nginx WordPress and another Web app URL structure
- Can I remove or edit an include() from a function with a filter?
- Creating customized php files in theme folder
- WordPress time queries
- How to put search bar & logo in the “primary navigation” storefront theme?
- I want to include a particular word into the excerpt of every posts of a custom post type. How can I do that pragmatically?
- Disclaimer that will show every refresh of the page
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Send an e-mail on address with the link with disliked post
- List sub categories and corresponding posts of a parent category
- Woocommerce My acount page
- IF statement not working – Any suggestions?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- Pages from admin dasboard missing after site migration
- How can I remember an action taken by a logged in user?
- Script to generate pages – taxonomies not loaded
- cant insert data in a custom table in phpmyadmin
- Invalid Argument foreach
- How to Link to category titles if it is in the single post content?
- How to add a PHP scripts into WordPress
- Closing Comments conditionally in comments.php
- wp_set_object_terms returns 500 error when called through AJAX function
- How do I send a POST request with params with WordPress REST API
- Create custom admin page with custom text fields
- Editable Student file associated with basic User ID
- html to posts, jpg to featured image, zip file contains jpg and html
- List categories assigned to a post
- Call get_template_part() custom permalink
- Two theme locations for two menus, but only one is showing up
- How to set the plugin load order when updating the active_plugins option?
- Display Year and Month from custom field + Age Calculator
- php string inside shortcode does not work
- Shortcodes (with a space) added to php Sample
- No Authors for custom post type
- Get author meta of all writers
- Creating a function that sanitizes the custom metabox excerpt
- Nav Menu Display
- WordPress & PHP sessions
- How to pass username into form that sends data to database
- How to add pagination for wordpress home page
- which php or css file has generated an inline style in WordPress that overwrites my css
- Change body_class() PAGE to HOME
- how to create twitter card without plugin in wordpress website?
- How to use phpspreadsheet reader with $wpdb