Post_object

The Post Object field type (e.g. ACF Post Object) creates an interactive dropdown to select one or more posts, pages, or custom post type items. This field type uses the Select2 library to enable search and AJAX functionality.

How to use it

In Advanced Views, if you add these type of fields to your Layout they will be displayed as links. For example you could use the field to link to a different post or post type or to create a read more link.

Display term details (Pro)

Sometimes, instead of displaying the selected post as a link, you may need to display some fields of the selected post with your current Layout. With Advanced Views Pro, you can do this.

To display post details, follow these steps:

  1. Install the Advanced Views Pro plugin, which allows you to customize the appearance of object fields.

  2. Create the Primary Layout: Start by creating the main Layout. Choose the target post_object field and publish to save your Layout.

  3. Create a ‘Post Details’ Layout:

    This Layout will be responsible for displaying post details.

    In the Fields tab, select the post fields you want to display, such as the WordPress excerpt and Featured image.

  4. Publish the 'Post Details' Layout: After assigning the fields, save the 'Post Details' Layout.

  5. Select the Field Layout:

    Go back to the primary (main) Layout.

    In the field row, select the Layout in the 'Field Layout' dropdown.

  6. Save the Primary Layout: Save the main Layout to complete the setup.

  7. Customize as Needed: Now, each chosen post in the post_object field will be displayed according to the Layout chosen in the Field Layout. You can further customize the markup and add CSS styles as needed in the CSS & JS tab.

That's it! By following these steps, you can display detailed term information and have full control over the display and styling.

Use a Relational field to 'link' two Custom Post Types (CPT) together. Combine it with a Meta Filter (Pro) to display related content.

As a list

To display all the items in a single row, you can use the CSS Flexbox:

#view__terms {
display: flex;
gap: 10px;
}

As a grid

To display all the items as a grid, you can use the CSS Grid:

#view__terms {
 display: grid;
 grid-template-columns: 1fr;
 gap: 20px;
 }

@media screen and (min-width:992px) {
 #view__terms {
  grid-template-columns: repeat(4, 1fr);
 }
}

Displaying items as a Grid (Pro)

Repeater items as a Grid

To display items as a grid, start by creating a detailed Layout for each item by assigning a Field Layout, as described above. Once your Field Layout is set, you can transform the display into a grid using CSS Grid. Simply add the following CSS code to your Layout to achieve the desired grid layout:

#view__post-object {
 display: grid;
 grid-template-columns: 1fr;
 gap: 20px;
}

@media screen and (min-width:992px) {
#view__post-object {
  grid-template-columns: repeat(3, 1fr);
 }
}

Make sure the class in the CSS fits the field class from the markup. By changing the value of the grid-template-columns property, you can control the number of columns in your grid.

Displaying items as a Slider (Pro)

Advanced Views comes with a set of pre-configured JS libraries, so you can easily turn the post object items into a slider.

After adding the repeater field to the target Layout, change the 'Enable Slider' option to 'Splide v4' and press the Save button. It'll automatically change the field markup to incorporate the necessary classes, and add the default JS instance:

var post_object = this.querySelector('.acf-views__post-object');
if (post_object) {
	/* https://splidejs.com/guides/options/ */
	new Splide(post_object, {
		type: 'loop',
		perPage: 1,
		perMove: 1,
	}).mount();
}

You can customize it according to your needs, using any available Splide options.

Last updated