Skip Navigation

[Resolved] Filter on archive not working and post title getting in loop wrong

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom post type called Companies with a repeating field group (RFG) called Company Locations. One of the fields in that RFG is an address field. On the Companies WordPress Archive page, I would like to show a Map with Markers for of all the Company Location posts. I would like to filter the Companies archive by a field in the RFG, and I would like to show a custom field from the parent Company in the marker popup.

Solution: It's not currently possible to filter a View of a CPT by fields on its RFGs.

To access custom fields from the Company post in a View of the RFG, use the item attribute in the shortcode with the syntax "@relationship-slug.parent".

[types field='company-logo' title='[wpv-post-title]' alt='[wpv-post-title] Logo' size='custom' height='100px' width='100px' resize='proportional' item='@company-branches.parent'][/types]
This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Sasank 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#955643
Capture.JPG

I created a filter for city on archive page but it is not filtering. The filed comes from a repeatable field group. Also all the markers on map are returning same page title and logo in the loop. Like you can see in the attached screenshot, marker needs to show Smart3Dme and its logo but is showing name and title from other listing.

please refer to
hidden link

#955678
Screen Shot 2018-07-25 at 1.39.39 PM.png

I created a filter for city on archive page but it is not filtering.
Unfortunately it is not possible to filter a View or WordPress Archive of posts by a custom field in a Repeating Field Group applied to that post type. You can filter a View of the Repeating Field Group by this custom field, then in the Loop of that View you can get information from the related Company post by using the "Post selection" tab in the field dialog (see screenshot).

Also all the markers on map are returning same page title and logo in the loop.
Remove item='$current_page' from this shortcode:

[types field='company-logo' title='[wpv-post-title item="$current_page"]' alt='[wpv-post-title item="$current_page"] Logo' size='custom' height='100px' width='100px' resize='proportional' item='$current_page'][/types]

You should only use item='$current_page' if this View is placed on the Company single post. Since the View is shown on an archive, you should remove it.

#955753
Capture.JPG
Capture2.JPG

Thanks for your reply Christian.

I did try without item='$current_page' at first but it didnt work which is why I had added item='$current_page'. Please see the screenshots what I am getting after removing item='$current_page'. Non of the markers are returning proper logo or title now. One think to do that the marker view is looping through address field inside Repeating Field Group.

I didnt quite understand what you suggested for the filter but will try to go through documentation ones again.

#956488

I have been trying a lot but couldnt find a solution to the issue yet.
Is there a way I could pass some arguments to short code? I saw that the view which I am using for markers is not getting the post id or title right, may be if possible could pass it as argument...

For the filter I guess I will have to wait till your team adds in the feature.

#956571

Please see the screenshots what I am getting after removing item='$current_page'. Non of the markers are returning proper logo or title now.
The Map Markers are created in View of Company Location RFGs, but the company logo is a custom field on the parent Company post. The syntax for accessing a custom field on a RFG's parent post is like this:

[types field='company-logo' title='[wpv-post-title]' alt='[wpv-post-title] Logo' size='custom' height='100px' width='100px' resize='proportional' item='@company-branches.parent'][/types]

The syntax uses the "item" attribute to specify the post context. 'company-branches' is the slug of this RFG, and '.parent' because we want to get the post value from the parent post. I made this change in your View and the images appear as expected now.

#956597

Oh ok! I had tried item='$parent' didn't know about .parent syntax. Thanks again for your help Christian and explaining about it.