How can I stop wp_update_post messing up HTML example code?

It was https://wordpress.org/plugins/syntaxhighlighter/ plugin’s fault. There are some functions in it that have something to do with this, namely encode_shortcode_contents_slashed_noquickedit, encode_shortcode_contents_callback. Now I replaced it to https://wordpress.org/plugins/crayon-syntax-highlighter/ but by the time I confirmed it was the other plugin’s fault I had already written a solution. function wpse190396_insert_post_data($data, $postarr){ if($postarr[‘filter’] == ‘db’ && ($data[‘post_type’] == ‘fix’ … Read more

SQL query to update post_date (one post = one single date & time)

I would not do this with SQL. A relatively simple PHP loop should work. function bulk_schedule_posts_wpse_105834() { $args = ( array( ‘cat’ => 1, ‘posts_per_page’ => -1, ‘post_status’ => ‘draft’, ‘post_type’ => ‘post’, ) ); $posts = new WP_Query($args); if (!$posts->have_posts()) return false; $date=”2013-08-01″; $times = array( ’10:00′, ’14:00′, ’17:00′, ’20:30′ ); while ($posts->have_posts()) { … Read more

Endless loop with wp_insert_post and wp_update_post

It sure can be written in a more efficient way (untested): $added = array(); global $wpdb; foreach($uniques as $unique){ $pagetitle = getTitle($unique); $new_post = array( ‘post_title’ => $unique, ‘post_status’ => ‘publish’, ‘post_type’ => ‘websites’ ); $pid = wp_insert_post($new_post); if ($pid) { $wpdb->query( $wpdb->prepare( “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, ‘%s’, ‘%s’), (%d, ‘%s’, … Read more

Updating a post without escaping ampersands?

That is correct, the updating in the Admin section does not change the & to & while the wp_update_post() function (which can be found under /wp-includes/post.php on line 3772) does but only when the user does not have the capability unfiltered_html, let me explain how I found this out, and what I recommend. I did … Read more

Keeping post_date same as the pending post_date on privately publishing the post

@Howdy_McGee is on the right track in his comment: by the time transition_post_status is fired, the post has already been updated (i.e., written to the db). What you need to do is hook into wp_insert_post_data, instead of transition_post_status, as follows: add_filter (‘wp_insert_post_data’, ‘mycpt_keep_pending_date_on_publishing’, 10, 2) ; function mycpt_keep_pending_date_on_publishing ($data, $postarr) { if ($data[‘post_type’] != ‘mycpt’) … Read more

Fill post titles from post content?

Hook into the_post – called when the post is actually used – and fill the title. Be aware the slug has to be changed too. If you are used not to enter a title, hook into save_post too, and let the same code do this for you. The code Download on GitHub <?php /** * … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)