• Resolved rubberdragon

    (@rubberdragon)


    Currently we are displaying results from a Custom Post Type using a Pods Template

    <div class="masonry">
    <div class="item"><img src="{@featured_image._img.large}<a href="{@websiteurl}"><h2 class="entry-title">{@post_title}</h2></a>{@post_excerpt}</div>
    </div>

    and shortcode on pages to generate the results,
    [pods name="listing" where="listingcategory.name='CategoryName'" template="TemplateName" orderby="RAND()"]

    Is it possible to amend this shortcode, so that results show only those listings that include the keyword that a user is searching, in the post_excerpt?

    e.g. to generate search results, I would like to amend the shortcode with the following where function:
    where post_excerpt. (includes searched keyword) or where post_title. (includes search keyword)

    Is that possible and what would be the searched_keyword field and what to use instead of = sign, to express includes!?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    You would use the parameters for ‘search’ instead in the shortcode:

    search="true" search_across="true" search_query="your search word"

    This would search the post_title and across custom_meta for the phrase or keyword in search_query.

    if you did only want to use it to look for something specifically in post_title or post_excerpt, you’d use:

    where="(post_title LIKE '%search keyword%') OR (post_excerpt LIKE '%search keyword%')"

    That would catch both conditions.

    Thread Starter rubberdragon

    (@rubberdragon)

    Thank you so much, great news. Added that to my page and now need to work out how to redirect search results to that page or how to edit search.php! Will update.

    Plugin Contributor Jim True

    (@jimtrue)

    typically with a form action and an input field, you can redirect to that page (ie, action="/search-form/", assuming search-form is the slug of the WordPress page you put that shortcode). Then it’s just a matter of passing the right Query variable into it.

    Thread Starter rubberdragon

    (@rubberdragon)

    Thank you. Will try that and update on progress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Show Results based on Search Query’ is closed to new replies.