Detect Post Type when publish_post is ran

publish_post will give you a second parameter if you ask for it. Notice the fourth parameter of the add_action call. That is your post object. function run_on_publish_wpse_100421( $postid, $post ) { if (‘news’ == $post->post_type) // your code } } add_action(‘publish_post’,’run_on_publish_wpse_100421′,1,2);

set role specific screen options in post summary page

I assume, you need something like editors can’t see the category column or something like this. This snippet might help you: /** Remove “Options”-Panel, when User is not admin **/ add_filter( ‘manage_posts_columns’, ‘change_columns_for_user’, 10, 2 ); function change_columns_for_user( $columns, $post_type ){ if( ‘post’ != $post_type ) return $columns; if( current_user_can( ‘manage_options’ ) ) return $columns; … Read more

WordPress get posts by date without query_posts

Yes, simple add a filter before you call it and remove it after you do function filter_where_wpa89154($where=””) { //posts in the last 30 days $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)) . “‘”; return $where; } add_filter(‘posts_where’, ‘filter_where_wpa89154’); $args = array( ‘posts_per_page’ => 5, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ … Read more

How to remove bulk edit options

A more reliable approach than messing with CSS would be to add some Javascript in the admin_head action, and basically override the built-in “inlineEditPost” function (located in wp-admin/js/inline-edit-post.js and easier to read in inline-edit-post.dev.js). I haven’t looked into it much specifically, but the brute force method would be to copy (and rename) that entire function … Read more

Hide comments awaiting moderation from user who submitted the comments

Check in your theme’s comments.php for the wp_list_comments() function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the functions.php file and outputs the template for comments. Within this comments template, you can then use wp_get_comment_status() and only display a comment if it was approved. Example from the Codex: … Read more