I am trying to: Get search results of different post types to be formatted properly
Link to a page where the issue can be seen:
hidden link
I expected to see:
formatting for the different post types and their relevant custom fields. I am using the plugin Better Search which is resulting in better results.
Instead, I got:
Only the Essay custom posts are formatted because I set it up in Search Archive - but I need conditionals for other post types such as Author, Gathering, Page
1. Please update all Plugins
2. I see that you edit that Search Results archive here.
hidden link
3. There is just one HTML markup on the Archive's Loop Content Template (Loop item in Archive for Home-blog Archives).
That HTML is applied properly here:
hidden link
To alter that HTML based on what Post Type is shown, you can use HTML conditional.
This is like when in PHP (or CSS) you say "If xy, then yx".
It's explained here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
You can check upon the Post Type of the posts with Views' Shortcode wpv-post-type:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153408
That means you can create a condition like:
[wpv-conditional if="( '[wpv-post-type]' eq 'post' )"]
HTML Markup For Posts
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-type]' eq 'another_type' )"]
HTML Markup For Another Post Type
[/wpv-conditional]
Does that solve the challenge?
Beda,
Thanks very much. Starting to understand the post type conditionals.
Best,
Will