Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-update-post]

The tag has no usage guidance.

-1
votes
2answers
2k views

Update post title from external file?

I have an external script I wrote (for admins only) that loads in the following at the top: require_once('./../wp-blog-header.php'); I'm aware that it can be a plugin, but it's just not right now.. ...
2
votes
1answer
412 views

How can I stop wp_update_post messing up HTML example code?

I'm showing little pieces of example HTML/PHP code on the frontend (with syntax highlighting). The entries are displayed as FAQ custom posts, and have a plugin (CMS Tree page) to alter the menu order, ...
2
votes
1answer
170 views

How do I batch create revisions of all posts?

I cleaned up an old-site from pasted tags, manually created lists, etc, and I'd like to keep the old posts as "revisions", so we can easily "compare" with the old posts and retrieve/revert the ...
0
votes
1answer
27 views

Update all WordPress posts's title and content then display them in a table

I am trying to update all the WP post title and content then show the just updated post to a table. I am using the following code but it does not work: $args = array( 'post_type' => 'post', '...
0
votes
1answer
18 views

Update around 200,000 posts

So I have recently migrated from a regular site to a wordpress CMS all via MySQL. I successfully was able to adapt the old database with that of WordPress. Now, the site has content in 3 languages. ...
0
votes
1answer
50 views

Why wp_update_post() does not update GUID?

I'm trying to update GUID on a attachment. But somehow it's not working neither it's throwing any error. Example Code: $my_post = array( 'ID' => 45, 'guid' =&...
0
votes
1answer
1k views

How to change post status from “draft” to “publish”?

My script uses code to set post content. I am also running the WP To Twitter plugin, to auto-tweet those posts. The problem is, whilst the plugin is correctly formulating its tweets using the default ...
0
votes
1answer
50 views

Cannot update page - with too many characters?

I have problem with page update. I am tring to save more than 14230 characters. After "update" worpress is moving me to "Posts" page. I show this issue on this video: https://youtu.be/3Y8qgFEizBU ...
0
votes
1answer
112 views

wp_update_post ignores if/else

I have a function that publishes a post if it exists as a draft. But the wp_update_post function seems to ignore the if/else and runs before anything else. $post = get_posts(array( ...
0
votes
1answer
471 views

How trigger to save post when updating post meta

I have very confused situation. I have added posts and all posts metas from one website db to another one, everything is fine, images, title, description of posts are there. But post metas are not ...
0
votes
1answer
18 views

how to update editor content from metabox

hello am trying to update and add editor content from metabox not using the default editor so i tried to use wp_update_post($array); but doesn't work it cause issue Fatal error: Maximum ...
0
votes
1answer
483 views

Updating post_parent by id (many times)

How can I update post_parent by ids? I tried: add_action('init','updating_parent'); function updating_parent(){ $args = array( 'post__in' => array(208,51) ); $my_posts = ...
0
votes
1answer
668 views

Update button (sometimes) greyed-out

I'd say about 50% of the time when I edit a post the 'update' is greyed out. What I do is copy the mark-up, refresh then re-apply and publish which is a bad work-around because it doesn't address the ...
0
votes
1answer
304 views

Change custom post status to draft before today

I tried this code which I made but looks like I am not doing it correctly.. The main problem is my code fetches all posts ordered by meta value date, but I need to hide the posts from the date today (...
0
votes
1answer
194 views

wp_update_post behaves differently for different user role

{ "sections": [ { "section_name": "Objective", "data": "<span style=\"font-weight: bold;\">Test</span>", "key": "ref" } ] } I am updating the above JSON data ...
0
votes
1answer
204 views

Setting a featured image while creating the post

I am creating a post with wp_insert_post/wp_update_post. The post should have a featured image. But to set a featured image I need the postID. The problem is I do not have any postID. What I am doing ...
0
votes
1answer
900 views

SQL / wp_update_post: change post custom field to CPT post taxonomy

the setup is as follow: I have posts with a custom field: actor = 'tom hanks' for advanced management I created a custom post type (actors) and added "tom hanks" as a post within that actors taxonomy. ...
0
votes
1answer
175 views

Update user from external script

I am using the API code of WordPress to update some fields of user profiles but I am having some problems. When I try to save information, it is not updating unless I click twice. For example for ...
-1
votes
1answer
2k views

Fatal error: Call to undefined function wp_cache_get after update attempt

I received the following error after attempting to update my WordPress to the latest version Fatal error: Call to undefined function wp_cache_get() in /home/fairmftt/public_html/wp-includes/option.php ...
3
votes
0answers
6k views

wp_update_post does not update post_name

I have a post with id=1, post_title = 'Some post title' and slug(post_name)='some-post-title. I want to update its title and slug. $update_args = array( 'ID' => '1', 'post_title' => '...
1
vote
0answers
30 views

When User Meta amended update Title and Slug of Post programatically

I have this code below which works perfectly, i.e. when adding a new User a post is programatically created in my CPT. add_action( 'user_register', 'add_member_employees' ); function ...
1
vote
0answers
174 views

how to transition to custom post status on post save

I'm trying to add a custom post status "Needs Review" for posts/pages that have been updated by an editor, so that admins can easily see what has been updated and review the changes. The planned ...
1
vote
0answers
55 views

why wp_update_post cant update when value is empty?

this runs successfully: wp_update_post( array('ID' => $postid, 'post_content_filtered' => 'something' ) ); but this doesnt update: wp_update_post( array('ID' => $postid, '...
1
vote
0answers
382 views

update a post with wp_update_post

I am using a wp_update_post to change the status of a post from published to pending using wp_update_post( array( 'ID' => $post_id, 'post_status' => 'Pending', ) )...
1
vote
0answers
80 views

wp_update_post() blank screen

i am developing in functions.php a function which, when a post in a certain category is created/edited, will create also a related page or update it if already exists. The creation of a new page with ...
1
vote
0answers
3k views

Set Attachment Image File URL as GUID

I have a form that uploads images and i want to update the GUID to be the attachment file url after WP generates the metadata. I tried to use wp_update_post, but seems that is not updating the guid. ...
1
vote
0answers
40 views

Set post_parent value for the images uploaded by Add Media button into post

I'm working on a front-end form plug-in and create shortcode to display front-end form on a page or post. While I was testing, I found all image files uploaded by Add Media button which will be ...
1
vote
0answers
2k views

How can I bulk update all posts without making changes?

I'm setting up a site which uses a custom vehicle auction theme. Using the WP All Import plugin, an XML file loads vehicle details into the theme, these are a type of post. In order for vehicles to ...
1
vote
0answers
152 views

Updating posts not working

Lets say I want to change a posts comment count to 50 everytime the post is viewed. I have this simple code in functions.php: function update_shares() { $my_post = array(); $my_post['ID'] = ...
1
vote
0answers
580 views

Update a post's info when clicking on a javascript button

I have a series of posts about various locations. I need people to verify if the location informaton is correct. The question is asked with two buttons for options. If "no" is clicked, they are taken ...
1
vote
0answers
168 views

Post author for revision not being set on update/insert

I'm trying to programmatically update a custom-type post with revisions enabled via form, and everything seems to be working fine except the post_author field for the revision is being set to 0 ...
1
vote
0answers
2k views

wp_update_post not working

I have the following code in a single script to be run one time to fix post names which are empty. // WP_Query arguments $args = array ( 'post_type' => 'books', 'name'...
1
vote
0answers
278 views

Changing random post publish time for repost

I have a lot of image posts. So, on weekends I don't work for that I want to re-post a random post. I made my own code. It schedules random post with its permalink too. $time= strtotime("+10 min") ...
0
votes
0answers
23 views

2 pages falied to update after installing Gutenberg

I have been updating a ton of client's Wordpress sites to the newest version and all has been going smoothly except for this one. There are 11 pages on this site and all but 2 updated with no issues. ...
0
votes
0answers
37 views

Programmatically create draft of existing post

Hi wordpress community, What I am trying to do is programmatically create an updated draft (not live) of a published post - so that the changes will be recorded but not published. Right now, my ...
0
votes
0answers
11 views

recursively update content

the problem I'm trying to translate a wordpress 4.7. But the site was consived in spanish and just now I installed the WPML plugin, now after 5000 post uploaded. I am using the visual composer and ...
0
votes
0answers
197 views

Bulk Post update_post_meta

how can use this code for update just post_meta ? here my code : function update_all_posts(){ $args = array('post_type'=> 'post', 'post_status' => 'publish', '...
0
votes
0answers
367 views

$wpdb->update query incrementing value on it's own!

I want to get value of column and increment it by 1. After increment, update the value in column.For example: In column post_likes the current value is 4. I am incrementing it by 1(like this $var++). ...
0
votes
0answers
64 views

Set a post to draft once depending on a post meta value (passed certain date)?

To give better context I have a CPT on my site called "Upcoming Games". I have the posts ordered by the datepicker: $args = array( 'post_type' => 'upcoming-games', '...
0
votes
0answers
521 views

Can I override the permalink/slug on creation

I have a plugin that imports data from an external API, creates a 'Product' Custom Post type ( or updates an existing one ) and then adds all the meta data. Every time we update the product from the ...
0
votes
0answers
130 views

Auto draft posts when scheduled date is reached

I have a plugin that allows all scheduled posts to be visible immediately... I'm looking for a function that will automatically set a post's status to "draft" when it reaches it's scheduled date and ...
0
votes
0answers
437 views

wp_update_post function ignores HTML tags

I have a custom plugin that moves posts from one category to another and then inserts text after the post is moved. This works fine except for I am trying to insert some CSS like you see below in the ...
0
votes
0answers
287 views

Function working in single.php but not working in custom template file

I defined in my functions.php the following code: function fix_footnotes($content){ return preg_replace('/href\s*=\s*"[^"]+(#[^"]+)"/','href="$1"', $content); } When I call this ...
0
votes
0answers
45 views

How to create posts with a specific date in bulk

I need to import posts with a specific date. They way I am doing it now is I import as draft, then I use php to publish, then use php to change the date. The problem is that if I make a mistake in ...
0
votes
0answers
406 views

Update Post with Modified Data

Task is to take class from <pre class="php"></pre>, and add that class to <code></code> and wrap all content of <pre> into <code> after that. I am querying WP with ...