PHP, Wordpress

Global search through wordpress multisite network

$searchfor = get_search_query(); // Get the search query for display in a headline
<h1>Search results for '<?php echo $searchfor; ?>'</h1>
$query_string=esc_attr($query_string); // Escaping search queries to eliminate potential MySQL-injections
$blogs = get_blog_list( 0,'all' );
$search = new WP_Query($query_string);
if ($search->found_posts>0) {
foreach ( $blogs as $blog ):
foreach ( $search->posts as $post ) {
$author_data = get_userdata(get_the_author_meta('ID'));
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<span><?php the_time('Y/m/d') ?></span>
By <?php the_author_posts_link();?> </p>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div id="entry-content"><?php
echo "Not Found";
restore_current_blog(); // Reset settings to the current blog

1 thought on “Global search through wordpress multisite network”

  1. This is a great plugin. Quick question, for some reason it’s only searching the page content, and not the page titles as well. Is there any way to fix this?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s