Creating/editing custom ‘post-state’

_post_states( WP_Post $post ) Parameters #Parameters $post (WP_Post) (Required) Code Reference from wordpress.org (https://developer.wordpress.org/reference/functions/_post_states/) function _post_states($post) { $post_states = array(); if ( isset( $_REQUEST[‘post_status’] ) ) $post_status = $_REQUEST[‘post_status’]; else $post_status=””; if ( !empty($post->post_password) ) $post_states[‘protected’] = __(‘Password protected’); if ( ‘private’ == $post->post_status && ‘private’ != $post_status ) $post_states[‘private’] = __(‘Private’); if ( ‘draft’ … Read more

Custom post status and preview

So actually everything were more simpler, as long as someone (namely me) would have looked how “draft” post status works. Apparently there are a lot of variables that wordpress codex does not reveal / has documented, such as the following: register_post_status(‘purchased’, array( /* ‘label’ => _x( ‘Purchased’, ‘post’ ), ‘public’ => false, ‘exclude_from_search’ => true, … Read more

Restrict a Post Types Post Status

I wonder if you could use something as simple as this: (similar to the suggestion of @ialocin) /** * Use the “Force” on the post status 😉 */ add_action( ‘wp_insert_post_data’, function( $data, $postarr ){ $change_post_status = array( ‘draft’, ‘private’ ); // Edit to your needs if( ‘cpt’ === $data[‘post_type’] && in_array( $data[‘post_status’], $change_post_status, TRUE ) … Read more

WP_Post_List_Table::get_views – Have post counts account for filters?

You might want to remove those counts and replace them with your own. function insert_post_counts($views){ //Run your query to count posts //use wp_cache_set and wp_cache_get to optimize performance $edit_url = admin_url( ‘edit.php’ ); $views[‘all’] = ‘All <a href=”‘.$edit_url.'”>(‘.$all_count.’)</a>’; $views[‘publish’] = ‘Published <a href=”‘.$edit_url.’?post_status=publish”>(‘.$publish_count.’)</a>’; $views[‘draft’] = ‘Draft <a href=”‘.$edit_url.’?post_status=draft”>(‘.$draft_count.’)</a>’; $views[‘trash’] = ‘Trash <a href=”‘.$edit_url.’?post_status=trash”>(‘.$draft_count.’)</a>’; return $views; … Read more

How to 301 private posts rather than 404?

Sorry guys, I found my answer: add_action(‘wp’,’redirect_stuffs’, 0); function redirect_stuffs(){ global $wpdb; if ($wpdb->last_result[0]->post_status == “private” && !is_admin() ): wp_redirect( home_url(), 301 ); exit(); endif; } Posts/Pages are removed from the sitemaps, but the page still shows up on the site so that it can get 301’d.

How can I run custom function when post status is changed?

See this Codex page. In general the hook is {old_status}_to_{new_status}. (Untested) but in your case, the hook would be pending_to_draft: add_action(‘pending_to_draft’,’wpse45803_pending_to_draft’); function wpse45803_pending_to_draft($post){ //Do something } You might want to look up the wp_transition_post_status function. You could also use the hook: transition_post_status add_action(‘transition_post_status’,’wpse45803_transition_post_status’,10,3); function wpse45803_transition_post_status($new_status,$old_status,$post){ //Do something }

How to display the status of users (online – offline) in archive.php

It looks like you’re close on this one. Move this function: function is_user_online( $user_id ) { // get the online users list $logged_in_users = get_transient( ‘users_online’ ); // online, if (s)he is in the list and last activity was less than 15 minutes ago return isset( $logged_in_users[$user_id] ) && ( $logged_in_users[$user_id] > ( current_time( ‘timestamp’ … Read more

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