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 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to create parallax effects using Rellax.js in Bricks

How to create parallax effects using Rellax.js in Bricks

This tutorial provides the JS & PHP codes that can be pasted in order to create smooth parallax effects using the Rellax.js library inside Bricks…
Categories:
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
Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

This Pro tutorial covers how posts of a Bricks query loop can be filtered to show only the ones whose true / false or checkbox…
Categories:
Tags:
Pro
Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

How to register a new dynamic tag for setting excerpt word limits and outputting an ellipsis (...) at the end.
Categories:
Pro
Testimonials Slider in Bricks

Testimonials Slider in Bricks

Setting up a dynamic testimonial slide that pulls the data from a CPT's post fields and custom fields.
Categories:
Tags:
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 1)

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

This tutorial provides the PHP & JS codes that can be pasted in order to create a dynamic map with markers populated from a custom…
Categories: