Captain Dando
Captain Dando

Reputation: 507

how might I create multiple search results pages, and direct different forms to their respective results page?

I have a complex setup on a site I am working on. It uses a mixture of taxonomies and meta data to contain a web of pages that represent different countries. each country has an author, and their content can be written by coauthors. I use a query to deal with the array of coauthors and make sure that that content appears on the page of each author within, though it does not lend itself well to search queries.

ob_start();    
    extract(shortcode_atts(array(
        'author' => '',
        'province' => '',
    ), $atts ));

    $post = get_post();

    if(is_page('testimonials') && empty($post->post_parent)) {
        $args = array(
        'post_type' =>  'shagun_testimonials',
        'order'     =>  'DESC',
        'orderby'   =>  'date',
        'posts_per_page'    =>  -1,
        'post_status'   =>  'publish'
        );
    } else {
        if(!empty($author)) {
            $authors = get_posts(array(
                'post_type' =>  'shagun_testimonials',
                'fields' => 'ids',
                'order'     =>  'DESC',
                'orderby'   =>  'date',
                'posts_per_page'    =>  -1,
                'post_status'   =>  'publish',
                'author__in'    => explode(',',$author),
                'nopaging'  => true,
                'posts_per_archive_page' => -1
            ));
        };
        if(!empty($province)){
            $multi_author = get_posts(array(
                'post_type' => 'shagun_testimonials',
                'fields' => 'ids',
                'nopaging'  => true,
                'posts_per_archive_page' => -1,
                'meta_query' => array(
                    array(
                        'key' => 'co-author',
                        'value' => $province,
                        'compare' => 'LIKE'
                    )
                )
            ));
        };
        if(isset($authors) && isset($multi_author)) {
            $options = array_merge($authors, $multi_author);
        }
        elseif (!isset($authors)) {
            $options = $multi_author;
        } 
        elseif (!isset($multi_author)) {
            $options = $authors;
        };

The problem now, is that these pages need a search form to search through only the content that applies to them. My idea is that I would have a search form that takes users to a page which uses the query above, but then just adds the search term as an additional filter, though I am not sure how to make it so that a form will be directed to a specific search results page instead of the default template.

Upvotes: 0

Views: 732

Answers (1)

Gert
Gert

Reputation: 370

i use this way to go to different forms

if($count==1 && $ccdate > $nn4date ){
    //this is for var text
    $stat="已&#23450";
    //this is for var button
    $but="删除";
    //this is for var form
    $form="can.php";
    } 

now in html

<form action="<?php echo $form; ?>" method="post">

you can do same for the button and custom message this way also ignore the funny variables in the if statement i have to use that to remember it lol

Upvotes: 1

Related Questions