-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
55 lines (52 loc) · 1.74 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
add_action('wp_head', function(){
global $wp_query;
$wp_query->set( 'orderby', 'post_title' );
$wp_query->set( 'order', 'asc' );
$wp_query->set( 'numposts', 12 );
});
?>
<?php get_header();
$search_page = get_page_by_path( 'busqueda' );
$search_page_url = get_page_link( $search_page->ID );
?>
<div class="card bg-dark border-light m-4">
<h4 class="card-header">Buscar más</h4>
<div class="card-body">
<?php get_search_form( true );?>
</div>
</div>
<div class="card bg-dark border border-light my-5">
<?php if ( have_posts() ) : ?>
<h3 class="card-header"><?php printf( __( 'Resultados de la búsqueda para "%s"' ), get_search_query() ); ?></h3>
<div class="card-body">
<div class="row">
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-md-3 mb-5">
<div class="card bg-secondary search-result">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'medium', array( 'class' => 'img-fluid card-img-top' ) ); ?>
<?php else: ?>
<img src="https://placehold.it/250x250" alt="" class="img-fluid card-img-top">
<?php endif; ?>
</a>
<div class="card-title text-center"><a class="text-white" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="card-footer">
<?php if (function_exists('fellowtuts_wpbs_pagination')) {
fellowtuts_wpbs_pagination();
} ?>
</div>
</div>
<?php else: ?>
<h3 class="card-header">No se encontraron resultados para "<?php echo get_search_query(); ?>"</h3>
<div class="card-body">
<p>Por qué no vuelves a <a href="<?php echo $search_page_url; ?>">intentar</a>?</p>
</div>
<?php endif; ?>
</div>
<?php get_footer(); ?>