Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.