searchform.php
Kód:
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Keresés" />
</div>
</form>
search.php
PHP kód:
<?php
$searchfor = get_search_query(); // Get the search query for display in a headline
?>
Keresési találat:<?php echo $searchfor; ?>
<?php
$query_string=esc_attr($query_string); // Escaping search queries to eliminate potential MySQL-injections
$blogs = get_blog_list( 0,'all' );
foreach ( $blogs as $blog ):
switch_to_blog($blog['blog_id']);
$search = new WP_Query($query_string);
if ($search->found_posts>0) {
foreach ( $search->posts as $post ) {
setup_postdata($post);
$author_data = get_userdata(get_the_author_meta('ID'));
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
the_excerpt();
?>
</div>
<?php
}
}
endforeach;
restore_current_blog(); // Reset settings to the current blog
?>
Saját formázásokat kiszedtem, azt úgy állítod be ahogy akarod. Már tippem sincs honnan szedtem a kódot, de én ezt használom.
Könyvjelzők