Skip to content

Instantly share code, notes, and snippets.

@lucasprogamer
Created February 7, 2018 14:42
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 lucasprogamer/98807579895563fe5a114ebc1340795d to your computer and use it in GitHub Desktop.
Save lucasprogamer/98807579895563fe5a114ebc1340795d to your computer and use it in GitHub Desktop.
attachments_per_post.php
<?php
function devplus_attachments_wpquery_where( $where ){
if( is_user_logged_in() ){
// we spreken over een ingelogde user
if( isset( $_POST['action'] ) ){
// library query
if( $_POST['action'] == 'query-attachments' ){
$where .= ' AND post_parent != 0';
}
}
}
return $where;
}
add_filter( 'posts_where', 'attachments_per_post' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment