Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Products are posts, sure, but not posts. “Post” can mean two things in WordPress: it can mean any post in any post type, or it can mean specifically the posts in the post type “post”.

    Products are posts, but their post type is not “post”, it’s “product”. That’s why you’re not seeing products, when the post_type parameter is set to “post”.

    You need to change the post_type parameter to “product” to see products, or “any” (or remove it) if you want to see all post types.

    Thread Starter stoelwinder

    (@stoelwinder)

    Thanks for that. That clarifies (a little) ??

    You need to change the post_type parameter to “product” to see products, or “any” (or remove it) if you want to see all post types.

    How would I do this specifically?

    Plugin Author Mikko Saari

    (@msaari)

    That would depend on how it’s done right now. It may be your theme settings, store settings, or perhaps it’s hardcoded in your search form.

    Thread Starter stoelwinder

    (@stoelwinder)

    How would I found out how it is done right now?

    Like for example, if I search for “thrustmaster” at this point in time, I get different results provided by different plugins. I want to have Relevanssi providing the search results and I’m not entirely sure whether that’s what’s actually happening:

    Woocommerce Instant Product Search Widget: The AJAX search results show TS-XW and TMX Pro as the first results. However, if I press enter in the search box, it brings me to:

    https://www.gameshome.com.sg/?s=thrustmaster&post_type=product&tags=0&limit=10&ixwps=1

    The above shows me the T-16000M FCS Flight Pack and T3PA as the first 2 search results.

    Mini Search: It shows me T-16000M FCS Flight Pack and T3PA as the first 2 search results (similar to pressing enter on the Instant Product Search Widget). But the URL is different:

    https://www.gameshome.com.sg/?s=thrustmaster&post_type=product

    Product Search: It shows me the same results as Mini Search because the URL is the same:

    https://www.gameshome.com.sg/?s=thrustmaster&post_type=product

    Search: This shows me no results based on the standard url:

    https://www.gameshome.com.sg/?s=thrustmaster&post_type%5B%5D=post

    If I change it to products (https://www.gameshome.com.sg/?s=thrustmaster&post_type%5B%5D=product) it will show me the same results as the other plugins (T-16000M Flight Pack and T3PA) but in a different format (a long list below each other).

    So, now my questions are:

    1. Are any of the results I’m seeing, the results that come from Relevanssi and how can I make sure that they are?
    2. How can I customise which page is called from the widget i use, like for example the Search widget?
    3. If I can get the widget to call Relevannssi search results, how do I now customize the actual results? Not the design or the layout, but how do I get say product A and B listed higher in the search results for certain keywords? I want to highlight the new products to ensure they get proper exposure during searches.
    4. Is there a way I can customize Relevanssi search results to show a banner for specific keywords (or similar keywords) that will click through to that brand’s landing page? Like I want to have Page A linked if keyword SEARCH is typed.

    Basically after all this trying and testing, I can’t seem to figure out what to do next to get Relevanssi working. I don’t know if it’s working, I don’t know how to get people to see the working results and I don’t know how to get Relevanssi configured and customized in a way that makes it practical for me.

    Really appreciate your suggestions and sorry to keep hammering on this. I really am at a loss here.

    Plugin Author Mikko Saari

    (@msaari)

    These are Relevanssi results: https://www.gameshome.com.sg/?s=thrustmaster&post_type=product

    These are too: https://www.gameshome.com.sg/?s=thrustmaster&post_type=product&tags=0&limit=10&ixwps=1 – the extra parameters do not matter, Relevanssi will just discard them.

    The AJAX search is not powered by Relevanssi. Most AJAX searches are not. SearchWP Live Ajax search uses Relevanssi.

    These are also Relevanssi results: https://www.gameshome.com.sg/?s=thrustmaster&post_type%5B%5D=post –?just nothing found, because you have no posts with the word “thrustmaster” in them.

    https://www.gameshome.com.sg/?s=thrustmaster&post_type%5B%5D=product doesn’t look right, because there’s extra garbage in the URL: that %5B%5D prevents your theme from recognizing the post type. Your theme shows the product search when post_type is set to “product”. Looks like Relevanssi doesn’t care about the garbage in the URL, but your theme does, hence the right results but the wrong look.

    Your second search box has this:

    <input type="hidden" name="post_type[]" value="post">

    It’s those square brackets: your theme doesn’t like them. Remove them, and change post to product to get a working product search.

    2. With the basic search widget, you can’t customize much. It’s what it is. If you want more customization, use a HTML widget and create your own search form. A basic search form looks like this:

    <form role="search" method="get" id="searchform" class="searchform" action="https://www.example.com/"> 
    <label class="screen-reader-text" for="s">Search for:</label> 
    <input type="text" value="" name="s" id="s" /> 
    <input type="submit" id="searchsubmit" value="Search" /> 
    </form>

    so you can start with that and customize from there.

    3. With Relevanssi Premium, you’d get some easy tools: you can pin posts so that when a certain keyword is used, that post comes up first. You can also give a boost for new posts, so that posts published within, say, a week, get a big boost.

    Without Relevanssi Premium, there are no easy tools to do that, but it’s possible to do lots of custom ordering with relevanssi_hits_filter filter hook; that just takes some skill with PHP and WordPress development.

    4. Not a Relevanssi question. This is best done by editing your search results template. The search keyword can be found in get_search_query(), so you can add something like this in your template:

    if (get_search_query() === "thrustmaster") {
        echo "<img src='https://www.example.com/thrustmaster-banner.jpg' alt='Thrustmaster banner' />";
    }

    That would print out an image if the search term is “thrustmaster”.

    The key here is that you do have Relevanssi working. The search is being powered by Relevanssi. There are just all sorts of extra trappings around it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search widget search post_type=post instead of post_type=product’ is closed to new replies.