• Resolved DT

    (@dolphintecnologias)


    Hi!

    I’m creating a custom search results page using the pods shortcode to list all pods of a certain name that contains the string searched by the user.

    I’m using Divi Theme so I created a Template and assigned it to be used with the Search Results page. So when you make a search on the site you will see the custom search results page instead of the default one.

    Now, I’m trying to get the searched string (standard “s” parameter on WordPress searches) and use it inside the “where” clause in the pods shortcode to filter them. I’ve tried a lot of options and could not make it work…

    This is the pods shortcode I’m using:

    [pods name="blog" where="post_title LIKE '%{@query.s}%'" orderby="date DESC" pagination="false" limit="-1"]
       <div class="titol">{@post_title}</div>
    [/pods]

    In this example I’m using the {@query.s} magic tag to get the search string, but does not work. I’ve also tried {@get.s} and {@request.s}, where “s” is the parameter with the search string in the URL, like this: https://www.myweb.com/?s=searched_text

    When I put the real searched string instead of the magic tag everything works fine, like this:

    [pods name="blog" where="post_title LIKE '%searched_text%'" orderby="date DESC" pagination="false" limit="-1"]
       <div class="titol">{@post_title}</div>
    [/pods]

    What am I doing wrong? Am I using the correct magic tag? Is there another way of getting this work?

    I’ll appreciate any help.

    Thanks in advance.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get WordPress search query parameter from pods shortcode’ is closed to new replies.