<?php
$args = array(
'post_type' => 'ht_tour',
'posts_per_page' => -1, //show all posts
'tax_query' => array(
array(
'taxonomy' => 'ht_tour_cat',
'field' => 'slug',
'terms' => 'upcoming',
)
)
);
$posts = new WP_Query($args);
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; ?>
High light Search Result In Wordpress add this function in your themes function.php function highlight_results ( $ text ) { if ( is_search ( ) ) { $ keys = implode ( '|' , explode ( ' ' , get_search_query ( ) ) ) ; $ text = preg_replace ( '/(' . $ keys . ')/iu' , '<span class="search-highlight">\0</span>' , $ text ) ; } return $ text ; } add_filter ( 'the_content' , 'highlight_results' ) ; add_filter ( 'the_excerpt' , 'highlight_results' ) ; add_filter ( 'the_title' , 'highlight_results' ) ; function highlight_results_css ( ) { ? > <style> .search-highlight { background-color : #FF0 ; font-weight : bold ; } </style> < ? php } add_action ( 'wp_head' , 'highlight_results_css' ) ;
Comments
Post a Comment