tigaman webdesign sopron
2022..1005.

Keresési eredmények példa – A search.php

Hozz létre egy search.php nevű fájlt. Illesszd be a következő kódot, töltde fel az aktuális sablonkönyvtárba.
Élő demó működik a webolodalon
[codeblock]

/// search.php
<?php get_header(); ?>
<?php $s=get_search_query();$args = array('s' =>$s);$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { _e("<h2 class='searchresults'>Search results for ".get_query_var('s')." word</h2>");?>
<?php while ( $the_query->have_posts() ) {$the_query->the_post();?>

<?php }}else{?>
<h2>No results</h2>
<?php } ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<h1><a href="<?php the_permalink() ?>" title="<?php the_title();?>"><?php the_title();?></a></h1>

<?php endwhile;endif; ?>
<?php
the_posts_pagination( array(
'prev_text' => __( '<i class="fa fa-arrow-left"></i>', 'textdomain' ),
'next_text' => __( '<i class="fa fa-arrow-right"></i>', 'textdomain' ),
) );
?>
<?php get_sidebar(); ?>

<?php get_footer(); ?>

[/codeblock]


Ajánlatkérés
AjánlatkérésMennyibe fog kerülni?