Support » Fixing WordPress » Search.php doesn't control the search output like it says in the codex!

  • Resolved GN2011

    (@gn2011)


    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.

Viewing 15 replies - 1 through 15 (of 18 total)
  • 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?

    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

    Thread Starter GN2011

    (@gn2011)

    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?

    Thread Starter GN2011

    (@gn2011)

    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]

    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.

    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?

    Thread Starter GN2011

    (@gn2011)

    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!

    Thread Starter GN2011

    (@gn2011)

    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.

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

    Thread Starter GN2011

    (@gn2011)

    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.

    Thread Starter GN2011

    (@gn2011)

    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)

    Thread Starter GN2011

    (@gn2011)

    Oh and – style.css

    Thread Starter GN2011

    (@gn2011)

    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

    Thread Starter GN2011

    (@gn2011)

    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

    Thread Starter GN2011

    (@gn2011)

    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..

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Search.php doesn't control the search output like it says in the codex!’ is closed to new replies.