• I have a new multisite install and have modified Twenty Ten for a series of blogs under my organization brand.

    I moved search to the header in the modified theme and it seems to be working fine, using the default function (no ‘searchform.php’ file exists).

    But the code I have is wired for the initial blog. So subsequent blogs using my theme are searching the db for the first blog. I thought maybe pointing to the root blog (not used) of the network would simply search across all the blogs in the network (which would be okay) but then it jumps to that blog for search results.

    What might be the missing bit for this? Here’s the code I inserted in the header.php file:

    <div id="placedsearchfield" style="float:right; width:280px; margin:50px 0 0;">
                  <form role="search" method="get" id="searchform" action="https://blogs.giarts.org/uteandtheaster/">
                    <div><label class="screen-reader-text" for="s">Search for:</label>
                        <input type="text" value="" name="s" id="s" />
                        <input type="submit" id="searchsubmit" value="Search this Blog" />
                    </div>
                  </form>
                </div><!-- #placedsearchfield -->
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi giarts,

    The search does not work in WordPress multisite, it will only work for the main blog. All the other sites you add, will have a broken search that list all your blogpost in the result with the newest blog post first.

    That’s not true, as demonstrated here: https://core.trac.www.ads-software.com/ticket/14476

    @giarts: Just set action="" in the form. This way, it will search the current blog, no matter if it’s the main blog or not.

    Thread Starter giarts

    (@giarts)

    Thanks scribu. I considered that a solution, but I’m not clear on how to get a separate header.php file for each blog in the network, which would appear necessary to have the action=”” set on a per-blog basis. (Seems like the mutisite network is using the same theme folder.)

    Is there an elegant, best-practice way to do this? Or does it amount to duplicating the theme for each blog in the multisite network?

    scribu: You are using WordPress 3.1-alpha in your test. It does not work in the most recent stable version. WordPress 3.0.1 have broken widget search on any site you create other then the primary site.

    Thread Starter giarts

    (@giarts)

    I’m actually outside of the widget. I went into the wp-includes/general-template.php file and pulled the code above from the get_search_form() function and put that in the header. I’m stuck with how to make the “action=” change to suite the various blogs in the multisite network.

    Thread Starter giarts

    (@giarts)

    I had success by correcting my mistake of placing the function code (above) into the header. Once I replaced it with the code <?php get_search_form(); ?> the header.php properly adjusted the action=”” for the current blog.

    Thanks for everything!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Search in Header for multisite network’ is closed to new replies.