Articles of wp update post

“Internal Server Error” with wp_update_post

I am coding a plugin for one of my sites which will toggle two pages statuses when a button is pressed. So when the ON button is pressed it will turn one page to draft while publishing the other, and vice versa with the OFF button. The problem I am having is that when you […]

how can I set the post author of a post I just created with php?

I’m using php to dynamically create a custom post, and I need the author to be someone other than the logged in user. I found this but I’m wondering if there is a way to do it after the post is already inserted. I guess I could just do a db query…

How to batch update post content with custom post meta value

I have a custom meta box, using WPAlchemy, in which I am looking to get rid of. However, I would like to get all posts that have a specific custom meta value set, and insert it into the begininning of the post content, then delete the meta value. I have a feeling this post gets […]

Change the post date from a meta box

I’m having a problem with updating the post_date in a custom function I’ve written. I’m trying to change the “post_date” to my custom “meta_date” value. Here is the function: function cfc_reset_postdate( $data, $postarr ) { // If it is our form has not been submitted, so we dont want to do anything if(defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) […]

How to generate slugs?

I have the following situation. I accidentally updated post_name column in wp_posts tables for all rows. Now I need to update those back somehow. I have researched that WP uses this function to generate slugs wp_unique_post_slug. Can anyone please provide me with steps how to do this? I have no idea of PHP, plugins etc. […]

How to disable saving/changing update date for certain admin users?

I have an admin user who is only for correcting the spelling errors and grammar stuff, however, when he corrects some post that is several hours or days old and just changes “People are gready” to “People are greedy” in the title or makes some other changes in the content, the update date is changed […]

Wp_update_post: Infinite loop even with remove_action solution, OOP

I have a quite complex PHP class, reponsible for creating and printing meta_boxes, generating and saving meta fields, … Each meta_box (object of class) has its own save function, that updates meta data of post (fields for them are instances of another class) as well as its post_excerpt and post_content. Yep, it’s probably a little […]

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 original content if needed. So I should either injecting the revision rows in the new DB or just naturally create them […]

Problem with wp_update_post

I’m trying to write a plugin that creates a page if a box is checked (value 1) and if the post id doesn’t already exist. If the post id does already exist, then I want to update the post with whatever changes have been made. I have the creating post (as page) part working just […]

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, at which these are displayed. Whenever I change the order, it calls a wp_update_post, updating ID, menu_order, post_parent, post_type. For debug, […]