Allow Post Author to be 0 on Update
Allow Post Author to be 0 on Update
Allow Post Author to be 0 on Update
Try this: $jobsTerms = get_terms(‘jobtype’,array( ‘taxonomy’ => ‘jobtype’ )); foreach($jobsTerms as $term){ $checked = (has_term($term->slug, ‘jobtype’, $post->ID)) ? ‘checked=”checked”‘ : ”; echo “<label for=”term-” . $term->slug . “”>” . $term->name . “</label>”; echo “<input type=”checkbox” name=”term” . $term->slug . “” value=”” . $term->name . “” $checked />”; } Replace $post_id with whatever you need to … Read more
You can use wp_get_post_revisions. <?php // some logic here $post_id = wp_update_post(/* … */); $latest_revision = array_shift(wp_get_post_revisions($post_id)); if ($latest_revision) { // do stuff with the latest revision // $latest_revision->ID will contain the latest revision }
Give this a try: if(get_the_modified_date(‘zY’)==date(‘zY’)) { the_modified_date(‘g:i a’); } else { the_modified_date(‘F j, Y’); echo ‘ at ‘; the_modified_date(‘g:i a’); } It checks that the modified date is the current day. If it is, it only displays the modified time. Otherwise it displays both the date and time.
You’re treating $my_post as an array, and then an object. Try moving ‘edit_date’ into the array. Also keep in mind that ‘post_date’ should be in your blog’s timezone. date will give the date-time in UTC timezone. See date_i18n() (codex: http://codex.wordpress.org/Function_Reference/date_i18n). From what I can see, everything else is corret.
Ah, I found the answer myself. I’ve added global $post before the loop and now all seems to works fine. I don’t know if this is a good practice, so if you have another ideas share them 🙂 Here is the revised code: add_action(‘save_post’, ‘bulk_refresh’); function bulk_refresh($post_id) { if($post_id != 123)//123 is the ‘certain page’ … Read more
The solution I arrived at is using the POST value of the submitted category title, so you always get what you entered and not what was saved before. Like so: function update_group($post_id) { $updates = array( ‘ID’ => 996, ‘post_title’ => sanitize_text_field($_POST[‘name’]) ); wp_update_post($updates); } add_filter(‘edit_category’ , ‘update_group’ );
Not sure, but seems maybe $data[‘post_status’] would be set to ‘trash’ at that point. If so, then you could just do something like… if ($data[‘post_status’] == ‘trash’) { return $data; } …before the other manipulations. EDIT That code should work then – but needs to be at top of the function, like… public function updatetitle($data) … Read more
As Codex says about wp_update_post: To work as expected, it is necessary to pass the ID of the post to be updated. Filling out the ID field is not strictly necessary but without it there is little point to using the function. So you must add newly created post ID to $posts to update it. … Read more
I was unable to find any action called wp_update_post. Are you sure it’s a valid one? Lets try the hook publish_post. add_action(‘publish_post’, ‘check_user_publish’, 10, 2); function check_user_publish ($post_id, $post) { $user_id = get_current_user_id(); if ($user_id != $post->post_author) return; $query = array( ‘ID’ => $post_id, ‘post_status’ => ‘draft’, ); wp_update_post( $query, true ); }} code not … Read more