Skip Navigation

[Resolved] Hide publications in archives until a search filter is performed

This support ticket is created 3 years, 1 month 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by dominiqueM-3 3 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1970913

Hello,

Tell us what you are trying to do?

In an archive page, I would like that no post is displayed below the custom search form until a search is performed by a user.
In other words, when the archive page is loaded for the first time user should only see the search form.
Same thing when the user resets the search.

Thank you

#1971137

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dominique,

Thank you for getting in touch.

Can you let me know if you are building your custom search using the Gutenburg Block editor or are you using the classic views editor ?

Once you've let me know then I can go ahead and provide the instructions accordingly.

Thanks,
Shane

#1971175

Hi Shane,

I made my custom search form and I built the archive loop by using Blocks.

Best regards

#1971217

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2021-03-01 at 3.07.34 PM.png

Hi Dominque,

Great in a case like this you will need to wrap your entire archive loop in a conditional block and using the advanced editor set the conditional to the following.

  ( ( '[wpv-search-term param='wpv_view_count' ]' ne '' ) ) 

Also see my screenshot for the advanced editor. Once you've done this, only when a search is performed will the results display. Otherwise it will be blank.

Please let me know if this helps.
Thanks,
Shane

#1971929

Hi Shane,

Thank you for your reply.

It is working for the the first load of the archive: only the search form is displayed and after a search, a list of posts is displayed as a result.

But when I hit the reset search button I can still see all the posts below the search form.

Could it be possible to also hide the list of posts on reset?

Best regards

#1972295

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dominique,

We are going to have to check the filter against another URL parameter that is added. The main issue is because the "wpv_view_count" parameter is always there it is guaranteed to ensure that your results display.

However with the AJAX refresh the parameter isn't removed when you click the reset button. Is there another field that you can guarantee that the users will search for ?

We can use this instead since all the custom fields get removed from the URL when the reset button is clicked. If so can you let me have a look at the search page and I can provide the correct parameter to be used.

Thanks,
Shane

#1972691

Shane,

In fact my project is still too drafty and I'm not sure if I should hide the list of posts yet.

From what you explain, a solution seems possible.

I would allow myself to reopen a question when the time comes.

Thank you again for your help.

Best regards

#1972693

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.