hartsook

Kadence Post Grid pass category as URL parameter

Mar 16th, 2026
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | Source Code | 0 0
  1. add_filter( 'kadence_blocks_pro_posts_grid_query_args', function( $args, $attributes ) {
  2.     if ( isset( $attributes['className'] ) && strpos( $attributes['className'], 'projects-grid' ) !== false ) {
  3.         if ( isset( $_GET['cat'] ) ) {  // 'cat' = your param name
  4.             $term_slug = sanitize_text_field( $_GET['cat'] );
  5.             $args['tax_query'] = array(
  6.                 array(
  7.                     'taxonomy' => 'category',  // e.g., 'category' or 'project-category'
  8.                     'field'    => 'slug',
  9.                     'terms'    => $term_slug,
  10.                 ),
  11.             );
  12.         }
  13.     }
  14.     return $args;
  15. }, 10, 2 );
  16.  
Advertisement
Add Comment
Please, Sign In to add comment