WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Search.php doesn't control the search output like it says in the codex! (19 posts)

  1. GN2011
    Member
    Posted 3 years ago #

    I just wasted around 10 hours solid trying to figure out why I couldn't get any styling on to my search results page via search.php.

    In the end I got so fed up with it I removed big chunks of code which should have stopped the search working altogether and it changed nothing.

    What is going on?

    Could somebody please tell me what file I need to adjust to style the search results output?

    Please, there has to be a simple answer to this question that is driving me insane!

    Many thanks.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    I've never had any problems using search.php in my own themes. The resulting display is exactly as coded in that template file. Are you sure that you are editing the search.php file for the correct theme?

  3. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Without seeing your search.php template file, your issue will be impossible to resolve.

    Going off of @esmi's question:

    Can you verify:
    1) The template file is named search.php
    2) The search.php template file is in the Theme root directory
    3) The Theme is the currently active Theme

  4. GN2011
    Member
    Posted 3 years ago #

    Thanks for the reply esmi!

    Yes i'm 1,000,000% sure i'm editing the correct one.
    I've even deleted all instances or search.php from all of the three themes in the directories (twentyten, twentyeleven & my child theme) just in case and it doesn't effect the search results at all. I would expect them to not work but this is not the case.

    The only thing I can think of is that maybe the Core is set to insert the standard search.php code dynamically in the event of bad code or a missing file but what is happening is that it's doing that all of the time and never actually reading the phsical search.php in the directory.

    Thoughts?

  5. GN2011
    Member
    Posted 3 years ago #

    Here is my search.php file.. It looks the same whether I use this or the default one (without added css code).

    [Code moderated as per the Forum Rules. Please use the pastebin]

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    If there's bad code in your child theme, WP won't substitute any other code in its place. Depending on your server settings, you'll see the relevant error messages when you display that page.

  7. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    The only thing I can think of is that maybe the Core is set to insert the standard search.php code dynamically in the event of bad code or a missing file but what is happening is that it's doing that all of the time and never actually reading the phsical search.php in the directory.

    Take a look at the Template Hierarchy. If search.php is not found, WordPress will fall back to index.php. That's probably what's happening; the question we need to resolve is: why?

    Can you post a Pastebin of your search.php template file?

  8. GN2011
    Member
    Posted 3 years ago #

    And this is how the search results look no matter what I do

    http://www.gnhousecall.com/v2/?s=house&submit=Search

    You can see that they aren't even following the div structure of the site, they are starting underneath the header!

  9. GN2011
    Member
    Posted 3 years ago #

    Here you go Chip - http://pastebin.com/vdNshCxH

    I've tried playing with the index.php and that doesn't make any difference either. It's like it's not using any of the regular template file to output the code into.

  10. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Can you list all the template files you have in your "housecall" Twenty Eleven Child Theme?

  11. GN2011
    Member
    Posted 3 years ago #

    Yep just tried altering the index.php in the twentyeleven theme just in case it was defaulting to that instead of my child's index.php but that's made no difference either.

  12. GN2011
    Member
    Posted 3 years ago #

    Here you go chip...

    404 Template
    (404.php)

    Footer
    (footer.php)

    Header
    (header.php)

    Main Index Template
    (index.php)

    Page Template
    (page.php)

    single-dj.php
    (single-dj.php)

    single-djs.php
    (single-djs.php)

    single-page.php
    (single-page.php)

    single-post.php
    (single-post.php)

    single-stations.php
    (single-stations.php)

  13. GN2011
    Member
    Posted 3 years ago #

    Oh and - style.css

  14. GN2011
    Member
    Posted 3 years ago #

    This is what happens if I remove the twentyeleven search.php and upload it to my child theme..

    http://www.gnhousecall.com/v2/?s=house

    Totally broken now..

    I've tried using it in this directory both ways as below..

    1) leaving ref's in the search code to 'twentyeleven' as is..

    2) changing them to the name of my child theme 'housecall'

    Neither way makes any difference

  15. GN2011
    Member
    Posted 3 years ago #

    Hmm ok, just looking at this comment in the search file..

    /* Include the Post-Format-specific template for the content.
    * If you want to overload this in a child theme then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */

    1) I'm guessing that "overload" should read "override"?

    2) What is the Post Format name? Where would I find this?

    Cheers

  16. GN2011
    Member
    Posted 3 years ago #

    Bloody hell. Haha!

    Ok I found out about post formats!

    I think this is why having the search.php file in my theme isn't working. Looks like I have to set up a post format in searchform.php, call it in search.php and create a new template called content-formatname.php to display the results!

    Does that sound right to you?

    Sounds a bit long winded just to get search results to me!

    None of this changes the fact that the twentyten/search.php isn't playing nice though..

  17. GN2011
    Member
    Posted 3 years ago #

    Ok, last thing i'm gonna post because this thread is getting big... (apologies)

    For clarification..

    1) I'm using a child theme of 'twentyeleven' called 'housecall'

    2) 'housecall' is the active theme

    3) There is no search.php in 'housecall'

    4) Here is the source of twentyeleven/search.php : http://pastebin.com/MXyw8JJh

    I've removed the default section & container divs and added some text to the file just to show that whatever I do or put into search.php isn't being parsed to the search results. It's being totally ignored.

    5) Here are some search results - http://www.gnhousecall.com/v2/?s=house

    If you 'view source' you will see that none of my edits have made it to the outputted page.

    Help! :)

  18. GN2011
    Member
    Posted 3 years ago #

    Fixed..

    Re-uploaded entire TwentyEleven theme and now it's updating perfectly!

  19. Sam Scholfield
    Member
    Posted 2 years ago #

    I had a similar problem, I changed the search form to look different, and it then stopped using the search.php file.

    If you have a similar problem, check your searchform.php file and make sure that the search inputs name is "s". Don't rename this to search or something else.

Topic Closed

This topic has been closed to new replies.

About this Topic