ACF Relationship Field Output

I’m using ACF and Themer with a relationship field to show which community a real estate listing belongs to. I have two questions.

  1. When I first set it up, I had the ACF type set to “Relationship” and couldn’t get BB to show it. When I changed it to “Post Object” it does. Is Relationship not supported?

  2. Now that I got it working, it outputs as an unordered list. Is it possible to just get the text?

Hi,

Beaver Themer supports the relationship field but only in the Post module.

CloudApp

If you use the Post module for your relationship field it should display correctly.

Okay, so now I understand why I couldn’t get it to work the first time. Unfortunately, using the Post module, I cannot add any other details I need.

But when I use an HTML module with custom layout I can add the relationship field using Post Object so I feel like I’m getting closer. Is there anything I can do to stop it from being an unordered list though?

Here’s a rough draft of what I’ve got:

using this code:

[wpbb post:acf_relational type='post_object' name='community_relationship'] — [wpbb post:acf type='text' name='property_location_price']

But I’d like it to be all on one line like this:
Gold Hill Mesa — $304,000

Hi @jodzeee,

You could use the Custom Content Shortcode plugin like that:

[related my_acf_relationship]
    [content field=image]
    [content field=link]
[/related]

Or, just think of it, use the Posts module, set the query (content tab) to ACF Relationship and build a custom layout in the Layout tab: this way, you should be able to have your text on a single line.

That’s what Danny suggested. The problem is, the “price” field I want next to the “community” relationship field is just a text field within the listing. Once I set the query to ACF Relationship, it doesn’t see the other fields as far as I can tell.

I just wish I could change the output of the post object to be text instead of an unordered list.

I’ll look at the plugin you suggested.

Not sure to understand.
If the Posts module is set to ACF Relationship, instead of Main or custom query, it fetches the related posts data.
I guess “price” is a field of the related posts, right?
If so, you use the Posts module custom layout and output the price using a Themer shortcode.
You can also add text or other shortcodes around this shortcode in the custom layout.
Or maybe i didn’t get the whole thing?

Can you specify the context?
Are you on an archive or single layout for instance?

No, “price” is a field in the single post I’m designing. The related “community” is a different CPT. So I’m trying to show which community this listing belongs to and the price field of the listing next to that. Does that make sense?

Yes, i understand you want to mix on the same text line, the output of a field belonging to the current post with several outputs of a field belonging to the related posts.
Maybe you could put the current post’s field in a column and the Posts module in a second column next to the previous, but it will be tricky.
Use CCS (Custom Content Shortcode), you’ll be able to mix the 2 outputs in the same text line. :wink:

Something like (dummy shortcodes, just for the example):
[themer shortcode for the current post field] - [CCS related] [CCS related posts data] [/CCS related]

Okay, I’ll check that plugin out - thanks!

Otherwise, I might just do it with CSS on the one I was able to do with the HTML module and relational post object. This seems to work.

ul { display: inline; list-style: none; }

Yes, much more simple with CSS.
I still doubt how you can get mixed data in the same <ul> though, i should have missed something about your data sources :wink:

If I use the HTML module with the following code, it outputs both fields. The problem I’m having with that is the first one (relational post_object) outputs as the UL. The second one outputs as plain text. So I found if I use CSS to make it inline, it brings them together like I want. I was just hoping I could get rid of the UL entirely and kind of wondered why it outputs like that in the first place.

<h1>[wpbb post:acf_relational type='post_object' name='community_relationship'] — [wpbb post:acf type='text' name='property_location_price']</h1>

I guess the <ul> is generated by the Themer shortcode to separate the different related posts.
The simpler solution in your specific case seems to inline the <ul> indeed.

I always find ways to make things complicated :slight_smile:

No, you look for the cleanest and efficient solution :wink:
Themer shortcode doesn’t handles ACF Relational correctly, you’re not the first one to fail with it.
If you’d had to build a more complex pattern, CCS could help, but here, i think the CSS tweak will do the job.

Dang. I just realized the post_object way of doing the relationship field results in a link being added.

I also noticed with taxonomies, you can turn off the list and the link:

[wpbb post:terms_list taxonomy='status_tax' html_list='no' separator=', ' linked='no']

Unfortunately, it doesn’t work with my relational use case, I wonder if that functionality can be added.