wp_update_post using post_name
$post = get_page_by_path( ‘the_slug’, OBJECT, ‘post_type’ ) ; $id = $post->ID; Then you an update post using this ID. Note: Untested, may contain syntax error.
$post = get_page_by_path( ‘the_slug’, OBJECT, ‘post_type’ ) ; $id = $post->ID; Then you an update post using this ID. Note: Untested, may contain syntax error.
It all depends on how your “custom fields” are saved. If you store the values as post meta then you would have to call the update_post_meta function to update them on wp_insert_post_data. In the example below Im setting the post meta “my_meta_key” with the string value “my_meta_value”. function save_my_post( $content ) { global $post; if( … Read more
wp_update_post The ID of the post if the post is successfully updated in the database. Otherwise returns 0. So just test again that. if ( $post_id != 0 ) { // success! write_here_show_success_messages(); } Or you can use an action. <?php /** use action for success message **/ if ( $post_id != 0 ) { … Read more
This function should be displaying both modified and published dates only if they differ. if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) { $time_string = ‘<time class=”entry-date published” datetime=”%1$s”>%2$s</time><time class=”updated” datetime=”%3$s”>%4$s</time>’; } Dates are compared using timestamps and if they don’t match the string format is set to two <time> tags otherwise it’s … Read more
The sticky posts info is stored in the sticky_posts option in the options table. It’s stored as serialized array e.g. a:2:{i:0;i:1272;i:1;i:1995;} You can modify it via the Options API but there’s a way to bulk edit posts in the backend: 1. Select the Sticky view: 2. Select all sticky posts and apply the bulk Edit … Read more
Actually, there are 2 issues in your code: You were using PHP custom file name instead of menu_slug. You were not using action and method attributes of form tag. When you were submitting form WordPress redirecting into admin.php?on=Turn+Registration+On which is not a valid page. add_submenu_page function 4th parameter must be unique menu slug of your … Read more
If you know the ID of the author you can use wp_insert_post specifying the ID and the author ID to it. $id = $post->ID; // change this to whathever $user_id = ‘4’; // change this too $the_post = array(); $the_post[‘ID’] = $id; $the_post[‘post_author’] = $user_id; wp_insert_post( $the_post ); The trick is to specify the ID … Read more
A Note: Actions and Filters are not really interchangeable: Filters typically must return the passed data or it’s going to break something. Building off of what m0r7if3r said, wp_insert_post_data is a filter, so you should be modifying the post’s $data and returning it at the end of the function. (Alternatively, you could global the variables … Read more
This is a stab in the dark, but have you tried using the set_object_terms hook for your bam_save_event_cat function? function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { $taxonomy = ‘categoria’; $tribe_cats = get_the_terms( $post_id, ‘tribe_events_cat’); foreach($tribe_cats as $tribe_cat) { if( empty($tribe_cat->name) ) continue; $catname = $tribe_cat->name; $cats[] = $catname; } wp_set_object_terms( $post_id, $cats, … Read more
A bare-bones version would look something like: function deny_post_date_change_wpse_131049( $data, $postarr ) { $user = wp_get_current_user(); // var_dump($user); die; // debugging if (in_array($user->ID,array(14,19))) { unset( $data[‘post_date’] ); unset( $data[‘post_date_gmt’] ); } return $data; } add_filter( ‘wp_insert_post_data’, ‘deny_post_date_change_wpse_131049’, 0, 2 ); I expect that in practice you probably want more complicated logic but that should get … Read more