Change default screen option value for posts per page

Just an addiction to @KrzysiekDróżdż answer. When viewing a specific post status the url query string variable ‘post_status’, is set to the name of the status, so you can use $_GET[‘post_status’] to narrow the effect of @KrzysiekDróżdż code only for pending posts: function my_edit_per_page( $result, $option, $user ) { $status = filter_input( INPUT_GET, ‘post_status’, FILTER_SANITIZE_STRING … Read more

Get only modified posts

You can use the posts_where filter: // Add custom filter add_filter( ‘posts_where’, ‘wpse_modified’ ); // Fetch posts $query = new WP_Query( $lastupdated_args ); where you can define the filter callback as: function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( current_filter(), __FUNCTION__ ); // Append custom SQL return $where . ” AND … Read more

Get post ID outside of the loop

here is a function that does just that: function get_lastest_post_of_category($cat){ $args = array( ‘posts_per_page’ => 1, ‘order’=> ‘DESC’, ‘orderby’ => ‘date’, ‘category__in’ => (array)$cat); $post_is = get_posts( $args ); return $post_is[0]->ID; } Usage: say my category id is 22 then: $last_post_ID = get_lastest_post_of_category(22); you can also pass an array of categories to this function.

Delete Post Link to delete post, its meta and attachments

Try using these delete links instead. Yours don’t seem to be formatted right. For delete: $delLink = wp_nonce_url( admin_url() . “post.php”, “post=” . $post->ID . “&action=delete”); For trash: $delLink = wp_nonce_url( admin_url() . “post.php”, “post=” . $post->ID . “&action=trash”); EDIT: No try this instead: $post_type = get_post_type($post); $delLink = wp_nonce_url( admin_url() . “post.php?post=” . $post->ID … Read more

Filter posts by author and category simultaneously

If you want your visitors to choose the category and author you can use the code below. If your loop in the template hasn’t been changed you should get away with adding a query to the URL like so: http://website.com/post-title/?author=1&cat=1 If you have a custom query you could do the following: $author = $_GET[‘author’]; //Get … Read more

Get current users post URL?

Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying “Hey WP just echo out this” – so it does it. You need to change it to: “Hey WP if the user is … Read more