Show Posts related to User - CPT / ACF + WP-Query String

Hi am sorry to ask, i hab been trying to find a solution for 4 straight hours without success and now hope for your help.

i have created a CPT called “members”

For my regular (articles) posts I have added a ACF “relationship” field, called “author” to select members. This field is set to return the ID (not object). So far this works, it outputs the member’s post ID when testing.

To display the members profile-page i have created a layout in Cornerstone.
I am tying to accomplish that beneath a members profile-information to also show 3-4 related articles of that member. I tried that by using a WP-Query-String but no matter what i try, posts are showing but not only the ones i hoped for, it just displays all posts, disregarding the query to only pull the ones with the right ID. For testing i hardcoded ‘342’ which is the ID of my own member-page, if it works i will replace it with {{dc:post:id}} in the member-layout.

I used the following args:

$args = array(
‘post_type’ => ‘post’,
‘meta_query’ => array(
‘key’ => ‘author’,
‘value’ => 342,
‘compare’ => ‘==’,
‘type’ => ‘numeric’
),
);
var_dump( http_build_query( $args ) );

OUTPUT:
post_type=post&meta_query%5Bkey%5D=author&meta_query%5Bvalue%5D=342&meta_query%5Bcompare%5D=%3D%3D&meta_query%5Btype%5D=numeric

Hello Florian,

Thanks for writing in!

You almost have the query string. You just need to use the ACF “Members” dynamic content to be added in your query string like this:
post_type=post&meta_query%5Bkey%5D=author&meta_query%5Bvalue%5D={{dc:acf:post_field field="members"}}&meta_query%5Bcompare%5D=%3D%3D&meta_query%5Btype%5D=numeric

If this does not work, we would love to check your ACF element settings. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Kindly let us know how it goes.

Hey Florian,

Your site couldn’t load on my end. If you’re using some IP restriction, please deactivate the restrictions while we investigate because we are located in different parts of the world so we cannot provide IP addresses to whitelist.

Thanks.

oh sorry i mistyped my domain name :slight_smile: its: entribe.org

maybe i was not clear in my initial post, the problem seems that any posts are pulled in by the query not just the ones that are associated to the members.

Thanks!!

Hi, I still hope you can help me here, thanks!

Hi, im not sure but it seems like someone of your team has looked into my site a few days before, but has not completed, is anyone still on it? thanks!

The Question is still why the following query string for the looper provider is not only outputting posts where the_author = the ID of the current post, but pulls in any posts disregarding the value of the_author

post_type=post&meta_query%5Bkey%5D=the_author&meta_query%5Bvalue%5D={{dc:post:id}}&meta_query%5Bcompare%5D=%3D%3D&meta_query%5Btype%5D=numeric

See Posts-Element in https://entribe.org/cornerstone/layouts/593

Thanks!

hi, can you pleas take a look at my ticket, is anyone of your team on it? thanks!

Hey Florian,

I am still checking (and scratching my head) why it is not returning anything. I also have forwarded this thread to my colleagues for further investigation.

Please bear with us.

1 Like

hi, i needed to go online in the meanwhile but i haven’t found the problem yet, do you have an idea?

Hey Florian,

The cause is still a mystery to us.

Please bear with us.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.