WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Search Widget not working (3 posts)

  1. roiabrazaldo
    Member
    Posted 9 months ago #

    Ok, I sweep alot of other topics and documentation and it doesn't help in anyway so I'm posting my problem. Please help.

    I'm making my own theme (from a scratch) reading documentations and tutorial I manage to make my theme working and its great and rewarding but as I dig deep for more features I came along with the default search widget given by wordpress. I manage to add it in my sidebar but when I search for something it throw me back to home page.

    It threw me back to home page because I didn't add a search.php page,
    so I added one, and now it throw me there.

    my problem is what should I put on that search.php to query the result of the search widget. I tried to follow this but it doesn't work.

  2. Toan Nguyen
    Member
    Posted 9 months ago #

    Simply, you need to create a php file in theme folder, its search.php, then write a loop condition as below:

    <?php
    if(have_posts()):while (have_posts()):the_post();
    	### for the title
    	the_title();
    	### for the content
    	the_content();
    endwhile;endif;
    ?>

    You can markup as your style in html, it will work.

  3. roiabrazaldo
    Member
    Posted 9 months ago #

    damn, why your code work, been there and done that mine didn't work.

    thanks man!

Reply

You must log in to post.

About this Topic