How to change my 3000 Published post status to Draft using PHPMyAdmin

If you have access to phpMyAdmin you can run this SQL query directly: UPDATE {prefix}posts SET post_status=”draft” WHERE post_status=”publish” If you do not have any experience with SQL queries then you should use this solution. Just place this code in functions.php and refresh the WordPress once, and it will be done. function setPostsToDraft() { global … Read more

Set page to draft on plugin deactivation

I’m posting this as another solution for you and its based on the page id /* $post_id – The ID of the post you’d like to change. $status – The post status publish|pending|draft|private|static|object|attachment|inherit|future|trash. */ function change_post_status($post_id,$status){ $current_post = get_post( $post_id, ‘ARRAY_A’ ); $current_post[‘post_status’] = $status; return wp_update_post($current_post); } So once you have this function you … Read more

How to list “invisible” Auto Drafts?

try pasting this in your theme’s functions.php file add_filter( ‘parse_query’, ‘display_autosave_and_revisions’ ); function display_autosave_and_revisions( $query ) { global $pagenow,$typenow; if ( is_admin() && $pagenow == ‘edit.php’ && $typenow == “post”) { $query->query_vars[‘post_type’] = array(‘revision’,’post’); $query->query_vars[‘post_status’] = ‘any’; } }

How to show or hide a post based on meta_value selection?

Use the pre_get_posts action to alter the main query with meta_query arguments to only select posts with active current_status. This example would work for your main posts page. See Conditional Tags for how to determine when other types of queries are run. function wpa_current_status( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $meta_query … Read more

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