Skip Navigation

[Resolved] Display on each entry in the loop which term matches with the custom search

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#916372

Hi, I've a custom search with few taxonomy filters. I need to display all the results that matches with any term of the search, so I set an OR relationship btw filters.

Then I also would like to display on each entry in the loop which terms match with that specific entry.

If I filter by:

TAX1 term1, term2
TAX2 termA

I'd like to display in the loop:

Entry1 title: term1, term2
Entry2 title: term1,termA
Entry3 title: term1, term2, termA
Entry4 title: termA

I tryed using:

[wpv-conditional if="( has_term('[wpv-search-term param='wpv-tax1']', 'tax1', null) eq '1' )" ]
[wpv-search-term param='wpv-eating-problem']
[/wpv-conditional]

But this works only if I select 1 term of TAX1, if I select more then one it doesn't.

Is there a solution?

#916474

Hello,

I have tried the steps you mentioned above, there isn't similar problem, see the live website:
hidden link
user/pass: xgren/111111
if you filter by:
TAX1 term1, term2
TAX2 termA

It does outputs all posts:
hidden link

view URL:
hidden link

And you don't need to [wpv-conditional] shortcode in this case, all can be setup in the view's filter

#916492

Hi Luo, I'm sorry, maybe I didn't explain very well the issue.

I want to display only the matching terms on results.

I mean, if I've this entries:

Entry1 title: term1, term2
Entry2 title: term1,termA
Entry3 title: term1, term2, termA
Entry4 title: termA

And I filter by:

TAX2 termA

I'd like to display in the loop:

Entry2 title: termA
Entry3 title: termA
Entry4 title: termA

If I filter by:

TAX1 term1
TAX2 termA

I'd like to display in the loop:

Entry1 title: term1
Entry2 title: term1,termA
Entry3 title: term1, termA
Entry4 title: termA

Maybe now it's clearer.

thanks

#916497

Did you try above test site?
1) I filter by:
TAX2 termA

hidden link

2) If I filter by:

TAX1 term1
TAX2 termA

hidden link

Both works as expected, you can get the credentials in above post:
https://toolset.com/forums/topic/display-on-each-entry-in-the-loop-which-term-matches-with-the-custom-search/#post-916474

#916499
YES.PNG
NO.PNG

Hi Luo, I know the filtering works fine and the result is correct, but I don't want to display any term under Tax1s column, if I'm only filtering by "termA". I only want to display "term1" in the Tax1s column (not "term1, term2") under Tax1s column if I'm filtering by "term1".

It's only an issue of what I want to display on each single the entry result output, it is not a filtering problem.

I've added two screenshots, the NO.PNG is what your search display, the "YES.PNG" is what I want.

thanks

#916592

Thanks for the details, I suggest you use shortcode [wpv-search-term] to get the URL parameter value, use it as condition in [wpv-conditional] shortcode, for example:

<td>[wpv-conditional if="'[wpv-search-term param="wpv-tax1"]' != ''"][wpv-post-taxonomy type="tax1"][/wpv-conditional]</td>
<td>[wpv-conditional if="'[wpv-search-term param="wpv-tax2"]' != ''"][wpv-post-taxonomy type="tax2"][/wpv-conditional]</td>

See the live test site:
hidden link

#916625

Hi Luo, It's what I tried, but I want to display all the matching terms, so maybe there are more then 1. Your code will display all the taxonomy of the entry if just one is filtered.

I tryed using:

[wpv-conditional if="( has_term('[wpv-search-term param='wpv-tax1']', 'tax1', null) eq '1' )" ]
[wpv-search-term param='wpv-eating-problem']
[/wpv-conditional]

But this works only if I select 1 term of TAX1, if I select more then one it doesn't.

If I have:

TAX1 term1, term2, term3, term4
TAX2 termA, termB, termC, termD

My entries are:
Entry1: term2, termB
Entry2: term1,term3, termB, termD
Entry3: term2, term4, termA, termB
Entry4: term4

I want it to display:

Entry1: term2, termB
Entry2: term1,term3, termB, termD
Entry3: term2, term4, termA, termB
Entry4: term4

but it displays:

Entry1: term2, termB
Entry2:
Entry3:
Entry4: term4

#917265

I have tried the steps you mentioned above in above test site, as your instruction:

select more then one it

See below URL:
hidden link

I can see it does display as your description:
https://toolset.com/forums/topic/display-on-each-entry-in-the-loop-which-term-matches-with-the-custom-search/#post-916625
I want it to display:

Can you confirm it?
Please correct me if there is anything missing, to avoid any more misunderstandings, you can use above test site to duplicate the same problem, thanks