Skip Navigation

[Resolved] Looking to display one return per search

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

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by Beda 4 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#1509249

I am trying to have the search results link directly to the partner page rather than display an unordered list with the partner name. For example, if searching 85234 / attorney - I would like the search result to direct me straight to Paulsen & Reissner page.

I have opened a ticket on this before and was told that there is a workaround but did not receive the custom code to accomplish it.

Link to a page where the issue can be seen:
hidden link

hidden link

#1510085

It seems you had marked that thread as "resolved" on your last reply, and Shane did not catch that you still need help with this.

To accomplish the result Shane describes in a View or Archive after running a search, you'd simply insert the "Post Body" (and whatever else you want to display on that search result) in the Loop Item Template (the content template assigned to the View or archive Loop).
That can be done with ShortCodes, which are generally available in the "Fields and Views" Button of the text editor when editing that Loop Item template.

If you edit all this with Blocks, it'll be similar, you'll find the "fields and text" block (for example) which you can use to display fields and text, or you can insert just single fields, of post or custom source, inclusive the post body, which will be what you majorly want to display.

You can see more information about these workflows here:
https://toolset.com/documentation/user-guides/views/using-a-view-template-in-a-view-layout/
https://toolset.com/2019/06/visually-create-and-design-views-using-block-editor/

Please let me know if this helps!

#1514897

I made the edits to the content template (Loop Item in HOA Partner Search) to insert the areas I want displayed but it still brought up the search result list rather than linking directly to the partner page. As for the content template, I believe it should still stay as the HOA Partner Template that is already assigned to the view.

Is there an alternative way I can get the search results to link directly to the specific partner page and bypass the search results page?

#1516045

I'm not sure to understand.

There is no possibility to link to a single post if you are visiting an Archive or list.
IN that list, yes, there you can link to single posts, so when clicked the single post is seen.
That's done with the Post title with Link shortcode or Block in Toolset

From the other thread, however, I understood you agreed with Shane to make a view of the fully post body for EACH post in that list.
That is done with the post body as mentioned in my previous reply.

At this point, I think it is best (if above does not help) you could describe precisely what you are doing and what you expect, and what happens instead, step by step, with links to the locations on your site where you see the problem
Log in details could help me to see the backend so to understand the setup even closer, and then, I can eventually suggest a solution, if it is possible to achieve, or a workaround, if not.

I've enabled a private reply as well, so you can add login details if this is required to understand the goal better.

Thanks!

#1517881

Thanks, I understand now.
This is not what Shane suggested as a workaround and what was implemented with the Post Body ShortCode.

See, that Search result is a WordPress Query, and it will show one, or more results potentially.
That's why those can't lead to a single result.

In google for example, if you search by anything, you'll get many results.
You can click on one and you'll be lead to the actual page.

That is the same with the kind of search results of Views, or in an Archive.

It seems in your case each query can return only ONE result.
And you want to bypass that ONE result, and lead directly to the actual post.

If you want to do that you do not need Views, to query the database and find (potentially many) results.
You would only need a Select or Text input and when a Submit button is pressed, you'd need to redirect to the your-site.com/your-post-slug to which the ONE results correspond.
This could be done with several approaches but all would involve some custom code, likely.

You'd need to get the post to which that ZIP code belongs to (that's I guess why you use Views for it, which helps build that query and show the result), and then instead of displaying the result, you would have to get the slug of that post and append it to the URL and redirect to that URL on Submit of the "search".

However, this is an unusual approach, because a query usually will return more than one result, which then will make such redirect impossible, because there would be MANY posts to redirect to.
Are you sure your search results always will be only showing ONE possible outcome?

In this case, it is probably easier to generate some form of Select field or text field without Views and create a custom action on Submit, that redirects to the post where that ZIP applies to.
For this Views could be used, together with its API https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results
This helps you get results of a View, without actually inserting the View results in a page, so you could use that to generate results for your ZIP query and take that result to perform a redirect

But I am not suggesting this, as it will break as soon you've more than one result each query term.