0

this is my query, It works well.

$args = array(
            'post_type' => 'post',
            'post_status'   => 'publish',
            'cat'=> $category,
            'date_query'    => array(
                'after' => $date_from,
                'before' => $date_to,
                'inclusive' => true,
            ),
            'order' => 'DESC', 
            'orderby' => 'date',
            'posts_per_page' => get_option('posts_per_page'),
            'paged' => $paged, 
        );

    $custom_query  = new WP_Query( $args );

this is my form

<input type="text" class = "advanced-search-input" id="searchText" name="search_title" placeholder="Título">

    <input type="text" class = "advanced-search-input" id="search_title" name="content" placeholder="Contenido" value="<?php echo isset($_POST['search_title']) ? $_POST['search_title'] : '' ?>">
    <input type="text" onfocus="(this.type='date')" onblur="(this.type='text')" class = "advanced-search-input" id="search_from" name="search_from"  placeholder="Desde" min="2000-01-01">
    <input type="text" onfocus="(this.type='date')" onblur="(this.type='text')" class = "advanced-search-input" id="search_to" name="search_to"  placeholder="Hasta">
    <select id="search_section" name="cat" >
        <option value="" selected>Sección</option>
        <?php 
        $categories =  get_categories('');  
        foreach  ($categories as $category) {
            echo '<option value="'.$category->term_id.'">'.$category->name.'</option>';
        }
        ?>
    </select>

I want to search by title and content in the two separate inputs

<input type="text" class = "advanced-search-input" id="searchText" name="search_title" placeholder="Título">

<input type="text" class = "advanced-search-input" id="search_title" name="content" placeholder="Contenido">

enter something similar to this in the query, but obviously it doesn't work

'post_title' LIKE $_GET['search_title'],
'post_content' LIKE $_GET['content'],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.