Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created December 20, 2012 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/4349064 to your computer and use it in GitHub Desktop.
Save billerickson/4349064 to your computer and use it in GitHub Desktop.
<?php
/**
* Display Posts Lockdown
*
* Disables the ability to query by post status and certain post types
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/display-posts-lockdown
*
* @param array $args, WP_Query arguments
* @param array $atts, Shortcode attributes
* @return array $args
*/
function be_display_posts_lockdown( $args, $atts ) {
$args['post_status'] = 'publish';
$excluded_post_types = array( 'revision' );
if( isset( $args['post_type'] ) && in_array( $args['post_type'], $excluded_post_types ) )
$args['post_type'] = 'post';
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_display_posts_lockdown', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment