• Resolved fkoomek

    (@fkoomek)


    Hi all!
    Is it somehow possible to set WordPress to search multiple keywords? Like red+blue?

    I use this code to display specific search results on a page and I would like to be able to set 2 keywords.

    <?php 
    /*
    Template Name: Custom Search Page
    */
    $s = 'your search query';
    $args = array(
        's' => $s
    );
    // The Query
    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) {
        _e("<h2>Search Results for: ".get_query_var('s')."</h2>");
        while ( $the_query->have_posts() ) {
           $the_query->the_post();
                 ?>
                    <li>
                        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                    </li>
                 <?php
        }
    } 

    Thank you.
    Radan

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Search multiple keywords (php function)’ is closed to new replies.