# Display recently viewed products

You can use Post loop builder to show recently viewed products. Follow these steps:

1. Add Post loop builder
2. Select Query > Array \
   ![](/files/ZMy7tS6j7CwSQWVLmbZM)
3. Enter this array:

```php
return [
'post_type' => 'product',
'posts_per_page' => 4,
'meta_key' => '_last_viewed',
  'orderby' => 'meta_value',
'order' => 'DESC',
];
```

Important part is meta\_key "*last\_viewed".*&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.woohoo.dance/dynamic-data/display-recently-viewed-products.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
