Limit Items Dynamically

This feature is available in WP Ultimate Post Grid Premium

For some advanced use cases you might want to limit 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 grid or grid-with-filters shortcode:

[wpupg-grid-with-filters 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 post ID:

[wpupg-grid-with-filters id="my-grid" post_id="28;88"]

Or even exclude certain posts by ID:

[wpupg-grid-with-filters 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-with-filters id="my-grid" exclude_post_id="current_post"]

Another option is to limit by a specific author:

[wpupg-grid-with-filters id="my-grid" author="3;8"]
[wpupg-grid-with-filters id="my-grid" exclude_author="3;8"]

Instead of the author ID you can also use “current_user”. This can be used to have a grid that only displays post by the currently logged in user, for example:

[wpupg-grid-with-filters id="my-grid" author="current_user"]

Dynamic Filtering in the Block Editor

In the Gutenberg Block Editor you could either work with the shortcode or set those same parameters in the sidebar of the Grid or Grid with Filters Block:

Take note that you don't add the full shortcode here, only the parameters you want to pass along.

Dynamic Filtering for Category Grids

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

[wpupg-grid-with-filters id="my-category-grid" exclude_term_id="current_term;42"]
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.