Skip Navigation

[Resolved] replacing the WordPress search archive with a toolset search results archive

This support ticket is created 3 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 3 voices.

Last updated by Christian Cox 3 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#2122053

Ron

Hi Shane,

I have added the backup files to the same link.
There are two files that are 2 GB. Only if I excluded all files (plugin files, must-use plugin files, media library files, post revisions and spam comments) I was able to get it below 2 GB.

I hope it works like that. I have uploaded all 3 files just to be sure.

Kind regards

#2123463

Shane
Supporter

Languages: English (English )

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

Hi Ron,

I've restored the backup with the smallest filesize and will be using the other backup to get the plugins.

However can you provide me with the credentials? given that for these All in one backups i'm not able to create a new set of admin credentials while importing.

Thanks,
Shane

#2126723

Shane
Supporter

Languages: English (English )

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

Hi Ron,

I've restored the backup here
hidden link
However I need for you to log in with the credentials that you had sent to me and setup the site by activating the exact plugin that were active on your internal site so that I can begin to check on the issue.

Also please include the steps/links that would replicate the issue.

Thanks,
Shane

#2129515

Ron

Hi Shane,

We have set up the environment. Relevanssi (for searching) and code snippets (in order to add PHP code from Toolset) are activated.
When you search on the page now and use the page/post filter, the menu gets off and search results don't change to only posts for example, since there are still pages in between the results.

Kind regards

#2131911

Hi, Shane is unavailable this week so I'm checking in on his open tickets. I hope that's okay. I was reading through the comments so far and I can see that you and Shane were able to get a clone of your site installed in our sandbox area, and you were attempting to set up a post type filter in the search results archive. I'm not sure how successful this will be. I've seen other clients have lots of trouble setting up such a filter and eventually give up. I started testing by turning off all non-essential plugins and snippets, and activating a default theme. So far, the post type filter is not working well. I'll continue to test this tomorrow and do some additional research to see what is possible with our search archive and filter setup, and give you an update when I've completed that research and testing process. Thanks for your patience while i work through this one.

#2132897

Okay I was able to make some adjustments to the filter code and get the post type filter working...I think. You can check it out in the sandbox here, where I have searched for "campus". You can adjust the post type filter to see the results updating when you click "Submit":
All: hidden link
Posts: hidden link
Pages: hidden link

All the same plugins and snippets are active, as well as the child theme. Can you take a look and let me know if the results are more like you'd expect now?

#2137259

Ron

Hi Christian,
Thank you for your help.
We have tested the solution you posted and this actually works as we expected.
Could you indicate what you have changed so we can try this on our site?

Thank you

#2138195

Okay great, here is the updated custom filter code:

function search_filter($query) {
    if ( ! is_admin() && $query->is_main_query() ) {
        if ( $query->is_search && isset($_GET['wpv-post-type']) ) {
            $query->set( 'post_type', $_GET['wpv-post-type'] );
        }
    }
}
add_action( 'pre_get_posts', 'search_filter', 99, 1 );

That adjustment can be found in the custom snippet here:
hidden link

I also added a custom JavaScript snippet in the WordPress Archive here:
hidden link
You can open the JS editor in the Search and Pagination panel to see the custom code I added:

jQuery(document).ready(function($){
  $("form input[type='hidden'][name='wpv-post-type[]']").remove();
});

This code helps prevent a problem where the post type URL parameter is added multiple times when performing multiple searches.