Search form returning error and incorrect content

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search form returning error and incorrect content

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 1 month ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #41299
    ericbiboso
    ericbiboso
    Participant

    Hi, I am currently using your plugin for custom post type search feature on this page: https://wcca-gj.com/plan-room/

    It works great but now I am trying to create another search form to search users/members on my site on this page: https://wcca-gj.com/members-test/

    I am getting a critical error on the site and I know what is causing the error. However, on the page that shows the error, which should be the results, it shows content from the other page with my other search form, the plan room page. It looks as though it is trying to return content from my custom post type, plan rom. I also triple checked that I am adding the correct form to the page.

    I have tried clearing all caches, creating a new search form from scratch and have also disabled the plugin causing the error. When I disable the plugin causing the error it removes the error but the results page displays the plan room posts, similar to how my other search form is working. So it looks like it’s attempting to return the wrong results page or the wrong content type in general.

    I attached a screenshot of the error page. I can’t figure this out so any help would be greatly appreciated.

    Thanks.

    Attachments:
    You must be logged in to view attached files.
    #41307
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I tried to visit the page in question (members-test), but currently it does not exist.

    My closest guess for the issue is probably that the results page might be trying to display post type results content, but likely it does not support it. Make sure that under the Search Sources -> Post type search there is nothing selected.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41431
    ericbiboso
    ericbiboso
    Participant

    I apologize but the members test page wasn’t published, I have published it so you can now view it: https://wcca-gj.com/members-test/

    Re Post types in the search sources, I don’t have anything selected. See attached screeshot

    Thanks

    Attachments:
    You must be logged in to view attached files.
    #41438
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you!

    Okay, I think I see what the issue is. It is actually caused by the fact that the plugin tries to push the member results to the results page, but the results page fails when it tries to display that. It happens, because WordPress results pages are only meant to display post type results. In this case is seems to be very specific for projects. The plugin gets by this issue by creating a “fake” post type object and replacing the post fields with the appropriate user details, unfortunately there is no better way of doing it currently with WordPress.

    My guess is, that the results page probably uses a custom loop/grid template or widget specifically made for only post types content, and during the processing of the results it may try to get a field value, which does not exist and it ends up in an error message.

    You could theoretically experiment with changing the results page, but I don’t know if it’s worth it. You could either use only the live search feature – or try to use the results shortcode as a custom results page for that specific search bar. With that solution you can keep the results page as is, and use another singular page for the member results.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41447
    ericbiboso
    ericbiboso
    Participant

    Ok thank you

    I created a custom results page and when testing it, it goes to a 404. It is currently active on my test page if you want to check it out yourself: https://wcca-gj.com/members-test/

    I am also using the Avada theme which has it’s own custom search.php template which is probably why this issues is happening. I removed/renamed that search template and unfortunately it didn’t make a difference.

    I’m curious, why would my other page that has a listing of posts from a custom post type that is using a search form I built with your plugin work but not another/additional search form? If you want to view the page: https://wcca-gj.com/plan-room/ You have to be logged in to view it.

    I haven’t tried the live search option but I’m assuming it probably won’t help. If you have any other ideas that would be great, I would love to get this working.

    Thanks

    #41475
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The other search form works, because it only has post type search active, it only searches “projects”, and the results page can handle that. If you were to enable members search (user search) on that form, it would very likely trigger the same error message.

    There was a minor misconfiguration issue with the members search, the custom URL was not set correctly (the query variable), I logged in and corrected that. After hitting the return button I am now redirected to the other page where the search is triggered and the results are displayed now.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41479
    ericbiboso
    ericbiboso
    Participant

    Hi Ernest, wow thanks so much, really appreciate the help on this and the explanation on why the projects form works vs the other form. It definitely makes sense now.

    I have tested the form and it is working for me as well now. Thank you for fixing that.

    If I were to try and get it working where the results display on the same page as the memebrs-test page, would that require a customization of the search template of my theme? It seems that I would just need to include the option to query users? What I have now should be good enough but there is a chance I may need to get it working where the results show on the same page, so i’m curious if it’s even possible.

    #41492
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You are very welcome!

    I think it would only require debugging where the error is coming from, what exactly is the culprit and then placing that piece of code into a conditional statement to check if the current object is indeed a project post type.
    You could actually do it with a users query, maybe by checking if the originating search query is coming from a specific search ID, something like:

    // Let's say if the search ID == 1, then it is the members search
    if ( isset($_GET['p_asid']) && $_GET['p_asid'] == 1 ) {
        // Make a users query
    } else {
       // Do the default query
    }

    It is not this simple for sure, as pagination and everything else needs to be considered, which is not a simple task to put together for sure.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.