• Resolved jimmyt1988

    (@jimmyt1988)


    code so far:

    <?php
        if(is_search()){
            if (have_posts()){?>
                <div class = "leftSideWrap">
                    <div class = "top"></div>
                    <div class = "middle">
                        <h2>Search Results:</h2>
                    </div>
                    <div class = "bottom"></div>
                </div>
            <?php } else{?>
                <div class = "leftSideWrap">
                    <div class = "top"></div>
                    <div class = "middle">
                        <h2>No results found</h2>
                    </div>
                    <div class = "bottom"></div>
                </div>
            <?php }
        } ?>

    I want to display the search query results like this:

    “You searched for: <?>,
    The search found <?> results”

    what goes at the <?> bit?

Viewing 9 replies - 1 through 9 (of 9 total)
  • My theme has a searchform.php and a search.php for the results.

    <p> Results for <em><?php echo $_GET['s'] ?></em></p>

    To answer your first question. I don’t know the answer for the second (yet).

    First bit:
    <h2>Search Results: <?php echo $_GET['s']; ?></h2>

    Second bit:
    <p>The search found <?php echo wp_count_posts()->publish; ?> results</p>

    Thread Starter jimmyt1988

    (@jimmyt1988)

    <?php echo $_GET['s'] ?>

    works perfectly. thankyou.

    Now I just need the post count. Know how to count how many posts are returned?

    Sorry this should be the second bit.

    <p>The search found <?php echo count($posts); ?> results</p>

    Thread Starter jimmyt1988

    (@jimmyt1988)

    As you can see, that is working perfecto!

    https://jamestrusler.co.uk/index.php?s=download

    Only problem now is that It’s returning the actual posts rather than the exceprts of the posts.

    A good example of what I mean is if you goto the blog page, there is a list of articles, with a “comment here link” at the bottom of each post.

    When you click on that link, it takes you to the actual post, its own singular page.

    When my search results are listed, they are returning the actual posts collectively, rather than giving links to all the posts in which you can click on the “add comment button” to visit the individual post.

    Thread Starter jimmyt1988

    (@jimmyt1988)

    I’m still unsure of this problem, anyone got any noodle tickling ideas ?? ?

    Like I said, I have a search.php for my search results and in that file I can use the_excerpt instead of the_content. If you don’t have a search.php your theme probably uses the index file (or maybe archive, I don’t know) which you might need to tweek

    Thread Starter jimmyt1988

    (@jimmyt1988)

    I created the theme, so I removed the search.php, I will place it back in and see what happens. Thanks in advance!

    Thread Starter jimmyt1988

    (@jimmyt1988)

    Looking better:

    https://jamestrusler.co.uk/index.php?s=download

    Thanks alot man!

    P.S, it’s perfect. Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Search bar help’ is closed to new replies.