I am trying to display the selected terms next to the headers in my custom search.
See attached images
Also see this page hidden link
The search is for the post type "Psykologer", the section "Psykologhuse" is a post type also, and it has a post relationship with "Psykologer".
I will (later) have each section working as an accordian (if it's even possible), therefore I am displaying the selected terms next to each headline, to view my selections also when the section is collapsed.
It is working for the taxonomy section and the custom field sections.
For this post relationship it is showing ID's and not titles.
I'm using this shortcode:
[wpv-search-term param="wpv-relationship-filter"]
This is the full section:
<div class="gruppe-header">
[wpml-string context="wpv-views"]Psykologhuse[/wpml-string]
<span class="vaelgte-filtre">[wpv-search-term param="wpv-relationship-filter"]</span>
</div>
<div class="clearfix"></div>
<div class="gruppe-filtre">
[wpv-control-post-relationship ancestors="psykologhus@psykologhus-psykolog.parent" autocomplete="off" format="%%NAME%%" url_param="wpv-relationship-filter"]
[wpv-control-post-ancestor type="checkboxes" output="legacy" label_class="txt-label" ancestor_type="psykologhus@psykologhus-psykolog.parent"]
[/wpv-control-post-relationship]
</div>
Also - I think this is related to my subject, PLEASE LET ME KNOW IF I NEED TO OPEN SEPERATE CHAT 🙂
can I somehow access more data from this post relationship to display in the search form?
Currently I've had to change the titles of the posts in "Psykologhuse" just to display the streetname in the checkbox labels, but I'm using this title all over the site, so it's not optimal. (E.g. look at the psycologists portraits, they also have the streetname added in top right corner.
best regards
Lykke
Dear Lykke,
Thanks for the details, I can log into your website, will update here if there is anything found
Here are what I found:
Q1) For this post relationship it is showing ID's and not titles.
It is expected result, the shortcode [wpv-search-term] can only display the URL parameter value, for example below URL:
hidden link
As you can see in above URL, there are two URL parameter with the same name "wpv-relationship-filter", their value are parent "Psykologhuse" post IDs, so it conduct the issue you mentioned above:
For this post relationship it is showing ID's and not titles.
In your case, you can setup a post view:
hidden link
- Query "Psykologhuse" posts
- filter by:
Include only posts with IDs determined by the URL parameter "wpv-relationship-filter" eg. yoursite/page-with-this-view/?wpv-relationship-filter=1
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/
- Display "Psykologhuse" post information
Then use above view's shortcode to display the searched "Psykologhuse" posts:
[wpv-view name="displaying-a-search-term-from-a-post-relationship"]
I have tried it in your website. it works fine.
Q2) can I somehow access more data from this post relationship to display in the search form?
Unfortunately, there isn't such kind of built-in feature within Views plugin:
You can only use %%NAME%% or %%COUNT%% as placeholders.
See screenshot wpv-control-post-ancestor.JPG
Hi, thank you so much for your help, you're right it's working, only one problem left, when I load the form, before I select something, it displays all of the post types, when I select one, it displays it correctly 🙂
Thanks,
Lykke
That is expected result, if there is any URL parameter passing to view, view will output all results.
You can use [wpv-conditional] shortcode to check if there is URL parameter "wpv-relationship-filter" then display above view's shortcode, for example:
[wpv-conditional if="('[wpv-search-term param="wpv-relationship-filter"]' ne '')"]
[wpv-view name="displaying-a-search-term-from-a-post-relationship"]
[/wpv-conditional]
More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/
Hi again,
It solved my issue.
Another issue - about the same - showed up when I put the "search" button in header.php to display on all pages, now it somtimes repeats the search terms, when I change the search many times.
Red button in right side of browser on all pages hidden link
See image
Thank you for your time
Best regards
Lykke
I assume the original question of this thread is resolved, for the new question, please check the new thread here:
https://toolset.com/forums/topic/showed-up-when-i-put-the-search-button-in-header-php-to-display-on-all-pages/