List taxonomy terms for post as checkboxes

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

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: From what I can see, everything else is corret.

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