Display Random Author with Details in Sidebar

Your best option is to get a random post author which is a user ID so here is a function to do just that: function get_random_author_wpa91320(){ global $wpdb; $id = $wpdb->get_var(” SELECT post_author FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” ORDER BY RAND() LIMIT 1 “); return $id; } And once you have that function in … Read more

has_archive=false on the default post type

Late answer. has_archive applies only for the rewrite arguments. In Detail If has_archive is set to true, then the $archive_slug will get set to the rewrite[‘slug’] argument. If then a rewrite[‘with_front’] arg is set, then this one will get prepended. The result of this will then get added as rewrite rule: add_rewrite_rule( “{$archive_slug}/?$”, “index.php?post_type=$post_type”, ‘top’ … Read more

Remove post title input from edit page

You can do this : add_action(‘admin_init’, ‘wpse_110427_hide_title’); function wpse_110427_hide_title() { if (current_user_can(‘subscriber’)) remove_post_type_support(‘post’, ‘title’); } This would hide title for subscriber. Replace ‘post’ with your custom post type

Display post number not post ID number

Post ID’s aren’t meant to be sequential. To number your posts sequentially, you’d have to use a meta field. There was discussion of this while back on this question: Change Permalinks Structure to a Sequential Number for Each Post? And the best answer for what you’re looking to do seemed to be a snippet of … Read more

Set tags for a post – without tag creation

OK, so you have something like this: $new_tags = array( ‘tag1’, ‘tag2’, ‘tag3’ ); wp_set_post_tags( $post_ID, $new_tags ); If you want to add only tags that already exist, then you have to filter your tags array: $new_tags = array( ‘tag1’, ‘tag2’, ‘tag3’ ); $existing_tags = array(); foreach ( $new_tags as $t ) { if ( … Read more

How to Display Network Post Count?

Made a couple of tweaks to brasofilo’s example as we were getting hit with memory execution issues; one of which may be related to a possible switch_to_blog memory leak that has been impacting sites doing a lot of switch_to_blog calls (we would typically run around ~1000 or so when loading this dashboard widget.) Even with … Read more

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