Skip Navigation

[Resolved] Display the results using a custom search from different posttypes

This support ticket is created 6 years, 1 month 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 6 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1148655
How must work.jpg
How i have it.jpg

Tell us what you are trying to do?
Search page where show results from different posttypes. Not all fields are showing (many to many relation ship) Search view only show fields from one posttype and need to show from both. Template is also only showing custom fields from one posttype and not from both.

view using
[wpv-control-post-relationship ancestors="werknemers@post-werknemer.child" url_param="wpv-relationship-filter"]
<div class="form-group">
<label>[wpml-string context="wpv-views"]werknemers[/wpml-string]</label>
[wpv-control-post-ancestor type="checkboxes" ancestor_type="werknemers@post-werknemer.child"]
</div>
[/wpv-control-post-relationship]

Is there any documentation that you are following?
Checked many views documentation

Is there a similar example that we can see?

What is the link to your site?
hidden link
hidden link

#1149095

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Say you have these post types and their custom fields:

Post type A
 - field A1
 - field A2
 - field Z

Post type B
 - field B1
 - field B2
 - field B3
 - field Z

Post type C is related to post type B
 - field C1
 - field C2

You have a View which includes both post types A and B in the results.

As the View iterates over the results in the output section, some of the results will be type A, others type B.

When the current post in the loop is type A, you can output fields A1, A2, and Z.

If you try to output B1, B2, B3, C1, C2, nothing will output because the A post has no such field.

When the current post in the loop is type B, you can output fields B1, B2, B3 and Z directly, and C1 and C2 indirectly (using the item shortcode attribute to specify that the field value comes from a related post).

If you try to output fields A1 or A2 nothing will output because B posts have no such values.

If you need to output different fields depending on whether the current post is type A or type B then you can use a wpv-conditional shortcode to first test the current post type (see https://toolset.com/documentation/user-guides/conditional-html-output-in-views/).

Depending on how you design your output, it could make sense to create separate content templates for the output of A type posts and B type posts, and selectively include either template within the wpv-loop tags using a wpv-conditional shortcode (so that you use the wpv-conditional shortcodes only once for each loop iteration instead of possibly multiple times for each field).

If you are adding search filters to the View, you can include filters for fields A1, A2, B1, B2, B3, and Z, but not C1 and C2 (this is currently not supported, but will be added).

#1151748

Hi Nigel,

Will check this in the next days.

#1151859

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, let me mark this as awaiting feedback from you.