Relationship Field
Using Advanced Custom Fields and Ajax Load More to display featured posts
In this example:
Ajax Load More will load a featured set of posts using the Relationship field for Advanced Custom Fields and the ACF extension.
The Relationship field for Advanced Custom Fields allows you to select from pages, posts, and custom post types to build an array of related content – Ajax Load More is used to loop over related items and display the results with infinite scrolling.
Note: When using the Relationship field remember to set orderby="post__in"
in your ALM shortcode and select Post ID
as the return type when creating your field in ACF.
View Screenshot.
-
Ajax Load More Post Example
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam quis risus eget urna mollis ornare...
-
Donec id elit non mi porta gravida eget metus
Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam id dolor id nibh ultricies vehicula ut id elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus...
The following shortcode was used to create the Relationship Field example.
[ajax_load_more preloaded="true" preloaded_amount="2" post_type="ajax_more" posts_per_page="4" orderby="post__in" acf="true" acf_field_type="relationship" acf_field_name="alm_featured_posts"]
Note: In this example, alm_featured_posts is the name of the Relationship ACF Field Group. Ajax Load More will loop over each post item in this Relationship Content field to build the infinite scroll listing.
The following Repeater Template was used to create the Relationship Field example.