Use a grid for the search or archive page

It's possible to use a WP Ultimate Post Grid grid for the search results page or taxonomy archive page by making some slight adjustments to the theme files.

To achieve this, start out by creating a new grid through the Grids > Manage page. Make sure the Data Source > Post Types include the post type that you want to see on the search/archive page. You should not use any of the "Limit Items" options here, as that will be handled by the plugin automatically.

Once you have the grid looking the way you want, you'll end up with a shortcode that looks something like this: [wpupg-grid id="your-grid"]

Instead of having a regular grid you'll want to add the takeover parameter:

  • [wpupg-grid id="your-grid" takeover="search"]
  • [wpupg-grid id="your-grid" takeover="archive"]
  • [wpupg-grid id="your-grid" takeover="query"]

The different takeover options

"search" should be used when putting the shortcode on a search page and will show a grid that includes ALL search results. This is not limited per page, so you probably want to combine this with a Pagination method.

"archive" should be used for taxonomy archive pages and will also include ALL term results.

"query" can be used for search, archive and any other WP_Query pages. It essentially displays the posts in the current main query as a grid. The difference with the above is that it's limited to the current page only.

Adding the shortcode to our theme files

Once you have the shortcode, you'll want to add it to your theme files to replace the default display method.

Where to replace things depends on the exact theme you're using. Usually there will be a search.php file and archive.php file where you could output the grid shortcode like this:

<?php echo do_shortcode( '[wpupg-grid id="your-grid" takeover="search"]' ); ?>

Take note that you'll also want to remove the regular loop displaying the posts, or you end up with both listed.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.