If modified on same day, show only time

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.

custom post scheduler for drafts

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.

Posts are duplicating on wp_post_update

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

Update post title with category name after editing a category

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’ );

wp_insert_post_data filter hook identify current action

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

Function to change post status IF current user and post author are the same

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

Display success message after wp_update_post

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

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