How to update all posts but the current one (post__not_in not working?)

There’s a more elegant way of updating your posts using the global $wpdb. function rsc_unpublish_all_ads( $post_id, $post, $update ) { // select all ads other than the current one $args = array( ‘nopaging’ => true, ‘post__not_in’ => array($post_id), ‘post_type’ => ‘rsc-ads’, ‘post_status’ => ‘publish’, ‘fields’=>’ids’ ); $query = new WP_Query($args); $published_ads = $query->posts;//array of post … Read more

How to get the Tags on Publish post hook?

Found Solution : If there is no data in the request_body, the we can also fetch it from the postID which is already we have. Changed Code: added condition if data not available, then get it from post id public static function saveDataInNotificationTable($ID,$request_body) { $post_data = json_decode($request_body); $tags = $post_data->tags; if($post_data == “” || $post_data … Read more

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

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