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: Users
Roles: 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 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Relationship Select Filter in Bricks

ACF Relationship Select Filter in Bricks

In the BricksLabs Facebook group, a user asks: I'm learning about ACF relationships and attempting to output a list of posts on any given page,…
Categories:
Pro
ACF Term Meta on Single Posts in Bricks

ACF Term Meta on Single Posts in Bricks

Consider this scenario: CPT: Project Custom taxonomy: Project Type Each project will be assigned only one project type. Project Type taxonomy's custom field: Project Type…
Categories:
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
Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

This Pro tutorial shows how we can prefilter the results of a query output by a Bricks query loop to only those for which the…
Categories:
Tags: