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

Related Tutorials..

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 ACF Relationship Query by Post Meta in Bricks

Filtering ACF Relationship Query by Post Meta in Bricks

How to filter the posts of a post type related to another post type based on the value of a True / False type ACF…
Pro
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.
Custom Function for ACF Link Field

Custom Function for ACF Link Field

How to output the label of an ACF link field through Dynamic Data.
Categories:
Tags:
Comma-separated user role names in Bricks

Comma-separated user role names in Bricks

How to display comma-separated names of user roles for the current user (in the loop) in a Bricks site.
Categories:
Pro
Post-specific ACF Repeater Galleries as Sliders in Bricks

Post-specific ACF Repeater Galleries as Sliders in Bricks

How to output ACF Repeater field rows with the images of the Gallery-type sub field as a slider.
Modifying ACF Field Value Before It Is Output

Modifying ACF Field Value Before It Is Output

Consider the scenario where a Page has a "Page Fields" field group created with ACF Pro like this: Field name: scientific_coordinators (type Repeater)|__ Sub field…
Categories:
Color Custom Field as Section Background Color on Category/Term Archives in Bricks

Color Custom Field as Section Background Color on Category/Term Archives in Bricks

How to use a color from a taxonomy term custom field for as the hero section background color on archive pages.
Categories:
Tags: