Advertisement
vapvarun

Exclude/Display Author blogs from Blog Index

Feb 6th, 2023
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | Software | 0 0
  1. /**
  2.  * List blogs with specific user ids
  3.  *
  4.  * @author vapvarun
  5.  * @link https://wbcomdesigns.com/
  6.  * @param object $query data
  7.  *
  8.  */
  9. function wbcom_display_author_blogs( $query ) {
  10.    
  11.     if( $query->is_main_query() && ! is_admin() && $query->is_home() ) {
  12.         //replace array values with user id
  13.         $query->set( 'author__in', array(1,26) );
  14.     }
  15. }
  16. add_action( 'pre_get_posts', 'wbcom_display_author_blogs' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement