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”]

Another option is to limit by a specific author:

[wpupg-grid id=”my-grid” author=”3;8″]
[wpupg-grid id=”my-grid” exclude_author=”3;8″]

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

[wpupg-grid id=”my-grid” author=”current_user”]

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″]