| @@ -24,8 +24,35 @@ | ||
| 24 | 24 | |
| 25 | 25 | // Check if we need to filter the grid dynamically |
| 26 | 26 | $dynamic_rules = array(); |
| 27 | 27 | if( count( $options ) > 0 && WPUltimatePostGrid::is_premium_active() ) { |
| 28 | + | |
| 29 | + if( isset( $options['post_id'] ) ) { | |
| 30 | + $post_ids = str_replace( ',', ';', $options['post_id'] ); | |
| 31 | + $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids ); | |
| 32 | + | |
| 33 | + $dynamic_rules[] = array( | |
| 34 | + 'post_type' => 'wpupg_general', | |
| 35 | + 'taxonomy' => 'id', | |
| 36 | + 'values' => explode( ';', $post_ids ), | |
| 37 | + 'type' => 'restrict', | |
| 38 | + ); | |
| 39 | + unset( $options['post_id'] ); | |
| 40 | + } | |
| 41 | + | |
| 42 | + if( isset( $options['exclude_post_id'] ) ) { | |
| 43 | + $post_ids = str_replace( ',', ';', $options['exclude_post_id'] ); | |
| 44 | + $post_ids = str_replace( 'current_post', get_the_ID(), $post_ids ); | |
| 45 | + | |
| 46 | + $dynamic_rules[] = array( | |
| 47 | + 'post_type' => 'wpupg_general', | |
| 48 | + 'taxonomy' => 'id', | |
| 49 | + 'values' => explode( ';', $post_ids ), | |
| 50 | + 'type' => 'exclude', | |
| 51 | + ); | |
| 52 | + unset( $options['exclude_post_id'] ); | |
| 53 | + } | |
| 54 | + | |
| 28 | 55 | foreach( $options as $taxonomy => $terms ) { |
| 29 | 56 | if( taxonomy_exists( $taxonomy ) ) { |
| 30 | 57 | $dynamic_rules[] = array( |
| 31 | 58 | 'post_type' => 'wpupg_dynamic', |
| @@ -49,8 +76,13 @@ | ||
| 49 | 76 | $posts .= $grid->draw_posts(); |
| 50 | 77 | $posts .= '</div>'; |
| 51 | 78 | |
| 52 | 79 | $output = apply_filters( 'wpupg_posts_shortcode', $posts, $grid ); |
| 80 | + | |
| 81 | + // Message when no items match filter | |
| 82 | + if( $grid->empty_message() ) { | |
| 83 | + $output .= '<div id="wpupg-grid-' . esc_attr( $slug ) . '-empty" class="wpupg-grid-empty">' . $grid->empty_message() . '</div>'; | |
| 84 | + } | |
| 53 | 85 | |
| 54 | 86 | $pagination = ''; |
| 55 | 87 | if( $grid->pagination_type() == 'pages' ) { |
| 56 | 88 | $pagination_type = $grid->pagination_type(); |