# Creating Your First Post Selection

### Step by step guide

{% hint style="warning" %}
Note: First [create a Layout](https://wplake.gitbook.io/advanced-views/getting-started/introduction/creating-your-first-layout) that you'll assign to your *Post Selection* below.
{% endhint %}

Visit the **Advanced Views** tab in the WordPress backend.

Switch to the *Post Selections* tab.

### Create a New *Post Selection*

Click on the **Add New Post Selection**.

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2Fkl7UBAfBdZYKvgacBhGb%2Fnew%20post%20selection.jpg?alt=media&#x26;token=80b3491e-188a-47c3-9ab8-a9066e5a11ed" alt=""><figcaption></figcaption></figure>

Enter a **Name** for your *Post Selection*.

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2FMDHVUd1k4OgHL8r2jCi0%2Fname%20post%20selection.jpg?alt=media&#x26;token=7da2c71d-6119-441a-9a2d-b0db19b12e62" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Note: If you don't give your *Post Selection* a Name then you can't publish your *Post Selection* and the publish button will be disabled.
{% endhint %}

### Assign a *Layout*

In the *Item Layout* dropdown, select your *Layout* to assign it to the *Post Selection*.

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2FDMrwOircxhxMXms0zcE7%2Fitem%20layout.jpg?alt=media&#x26;token=02ad6aab-97c9-4578-9fda-1b9b4b49697e" alt=""><figcaption></figcaption></figure>

Select the **Source -** 'Posts Query (WP\_query)' will get posts based on the defined query, while 'Page Context (archive pages)' will get posts from where the *Post Selection shortcode* is inserted (e.g. archive, author or category).

In the *Post Type* dropdown, choose the post type to filter by that post type.

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2FHxH8Jy4I6qeqgA2UkaoJ%2Fpost%20type.jpg?alt=media&#x26;token=edadccf2-f8a6-4705-8842-57f92e242009" alt=""><figcaption></figcaption></figure>

### Filter and Sort

In the *Post Status*, **add** one or more items from the list.&#x20;

Use the *Maximum number of posts* field to limit the amount of items shown.

For the *Sort by* dropdown, sort posts by date by **selecting** ‘Date’ from the list. (In Pro you can sort by Meta field)

**Choose** *Ascending* or *Descending* for *Sort order.*

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2FMGapS0uAqU77StIduhbI%2Fsort%20options.jpg?alt=media&#x26;token=5e355183-ee2d-4c99-8b99-30e9d565cf47" alt=""><figcaption></figcaption></figure>

### **Advanced settings**

**Switch** to the **Advanced** tab.

Give your *Post Selection* a description (only seen on the Admin *Post Selections* list).

**Customize** the 'No Posts Found Message' if needed.

In the *Pool of posts* dropdown you can manually **select** posts to limit the query to those posts only. Leave empty for the query to consider all items as per General tab.

For the **Exclude posts** you can manually exclude posts from your *Post Selections*.&#x20;

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2F7eXfzggWgzRmViXghrfH%2Fadvanced%20tab.jpg?alt=media&#x26;token=bc5fdddb-2981-4ad2-9512-7fe1c825e37c" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Warning: Don’t use Exclude posts together with *Pool of posts as it could give unexpected results or no results.*
{% endhint %}

#### Template Engine

Optionally change the [template engine](https://wplake.gitbook.io/advanced-views/templates/template-engines) from Twig to Blade (requires PHP 8.2).

### Publish your *Post Selection*

Click on **Publish** to save and publish your *Post Selection*.

### **Copy the shortcode into place**

**Copy** the generated shortcode of your *Post Selection* sidebar.&#x20;

<figure><img src="https://2293383029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN2nAC4pTDjEmDu8ZkLB2%2Fuploads%2FnTiCwrDJjsqKS9uIPcfT%2Fshortcode%20post%20selection.jpg?alt=media&#x26;token=15f956fa-706d-45c0-9c6c-a50470749ac4" alt=""><figcaption></figcaption></figure>

**Paste** the shortcode in your page, post or theme section.&#x20;

**View** the page to see the results.

{% hint style="info" %}
Note: Adding new fields to your assigned *Layout* will automatically include those fields in your *Post Selection* without you having to copy the shortcode into place again (Unless you have a Custom Template, then remember to include the new fields in your template).&#x20;
{% endhint %}

{% hint style="success" %}
Note: Restrict visibility of *Post Selections* by using user-with-roles="ROLE1,ROLE2" user-without-roles="ROLE1,ROLE2" shortcode arguments.
{% endhint %}

{% hint style="warning" %}
Note: Do you want to customize a query (WP\_Query) that is used to get *Post Selection*, but the option is missing in the interface? You can do this using our filters. [Read more here](https://wplake.gitbook.io/advanced-views/customization/filters-and-hooks/post-selection)
{% endhint %}


---

# 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://wplake.gitbook.io/advanced-views/getting-started/introduction/creating-your-first-post-selection.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.
