Skip Navigation

[Resolved] Formatting Custom Types in Search results (Archive)

This support ticket is created 6 years, 4 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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by WillL606 6 years, 4 months ago.

Author
Posts
#1097087

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

#1097376

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?

#1097845

Beda,
Thanks very much. Starting to understand the post type conditionals.
Best,
Will