Limit Posts Dynamically

This feature is only available in WP Ultimate Post Grid Premium

For some advanced use cases you might want to filter a grid dynamically based on certain variables. An example use case would be the inclusion of a grid on the taxonomy.php page and filtering that grid by that specific term.

In the Premium version this is possible by adding parameters to the shortcode:

[wpupg-grid id=”my-grid” post_tag=”1;3″]

This shortcode would use “my-grid” as it is and dynamically filter it before displaying, limiting it to only posts that are tagged with term id 1 or 3. You can look up those term IDs in the URL of the term edit page.

Instead of “post_tag” you can use any other taxonomy (like “category” or any custom taxonomy). It is also possible to dynamically filter posts by ID:

[wpupg-grid id=”my-grid” post_id=”28;88″]

Or even exclude certain posts by ID:

[wpupg-grid id=”my-grid” exclude_post_id=”9″]

Instead of an actual post ID you can also use “current_post” to represent the post ID of the page that is displaying the grid. For example:

[wpupg-grid id=”my-grid” exclude_post_id=”current_post”]

For category grids you have similar options by using the term_id and exclude_term_id attributes. For example:

[wpupg-grid id=”my-category-grid” exclude_term_id=”current_term;42″]