• Resolved genbeyond

    (@genbeyond)


    I am trying to make an Archive template that displays the search results for a particular query. I have done a similar thing before, looping through a particular Category, but I cannot figure out how to display search results.

    This is how I did the category loop:

    [loop type=post category='News']
      <div>
        <h2>[field title]</h2>
        <div>[field content]</div>
      </div>
    [/loop]

    I also managed to get the search term to show up like this:

    [pass global=query fields=s]
      Search Results for: {S}
    [/pass]

    Any ideas how I could use this to display a loop of applicable posts?

    • This topic was modified 5 years, 5 months ago by genbeyond.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Did you try something along the lines of:
    [loop type=post category=news value={S}]
    [field title]
    [/loop]

    Where are you setting the global parameter s?

    Hope this helps – didn’t test or try it, just initial thoughts…

    You may have to specify field…?

    I just added a post showing how I am doing something similar, except mine creates a global parameter called filter from within a form and then displays the results based on it..

    Thread Starter genbeyond

    (@genbeyond)

    Okay, I got it to kind of work using this:

    [pass global=query fields=s]
      <h1>Search Results for: {S}</h1>
      [loop type=post]
        [if field=title,content contains='{S}']
          <div>
            <h2>[field title]</h2>
            <div>[field content]</div>
          </div>
        [/if]
      [/loop]
    [/pass]

    It’s not a perfect replication of an actual WordPress search, but it’s good enough for me. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying Search Results’ is closed to new replies.