3rd Feb '24
/
0 comments

Limit Bricks Users Query to Current Post’s User-type ACF Field Value

Consider this scenario with ACF:

  • CPT: movie
  • Movie Fields field group
    • Author field of User-type
    • Field group location: Post Type = Movie
  • Author Fields field group
    • Author Title custom field of Text-type
    • Return Format: User ID
    • Field group location: User Role = Author

"John Briley" user:

"Gandhi" movie:

The requirement is to show John Briley as the author when Gandhi movie item is being viewed on the front end followed by a hyphen and John Briley's Title.

This Pro tutorial shows how this can be done in Bricks.

Create a template named say, "Movie" of type Single.

Edit it with Bricks.

Apply it to movie CPT.

Add a Section having Post Title and Post Content.

Add another Section having "Author" h2 Heading and a Container > Block.

Enable query loop on the Block.

Type: UsersRoles: Author

Add a Basic Text inside the Block having:

{wp_user_display_name} - {acf_author_title}

This should show all author users in the site. We need to filter this list to only the author that matches the current post's author post meta.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Repeater sub field value dynamic data condition in Bricks

ACF Repeater sub field value dynamic data condition in Bricks

This Pro tutorial provides the steps to output an element on single posts (can be of any post type) only if a specified ACF (Pro)…
ACF Relationship: Count of Related Posts

ACF Relationship: Count of Related Posts

Looking to get the number of CPT B posts related to a CPT A post when using a Relationship field with ACF? Here's a custom…
Categories:
Tags:
Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

This tutorial provides the PHP & JS codes that can be pasted in order to create a flying effect on map markers each time your…
Pro
ACF Checkbox Sub Field as Unordered List in Bricks

ACF Checkbox Sub Field as Unordered List in Bricks

Updated on 22 Sep 2023 This Pro tutorial shows how the checked options of a Checkbox-type of Sub Field inside a ACF Repeater field can…
Categories:
Pro
Custom Dynamic Data Tags for ACF Field Label, Prefix and Suffix in Bricks

Custom Dynamic Data Tags for ACF Field Label, Prefix and Suffix in Bricks

Bricks lacks built-in dynamic tags for ACF field labels, prefixes, and suffixes. This tutorial shows how to add them using custom dynamic tags.
Categories:
Pro
ACF Post Object Query Loop inside a Posts Query Loop in Bricks

ACF Post Object Query Loop inside a Posts Query Loop in Bricks

How to loop through a CPT and within each post, output a list of related posts.
Categories: