I’m using WPAS (WordPress Advanced Search) and i’d like to search by tag_id name and not slug.

My wp-admin link look like:

wp-admin/term.php?taxonomy=leasing-auto&tag_ID=3&post_type=autoturism

As you can see tag_ID=3 and it looks like:

Name : a-name
Slug : a-name-something-that-i-dont-want-to-appear

Problem:

My search needs to be by name and not by slug.
At the momment if i write a-name will throw an error as it doesnt find, buuut, if i search for a-name-something-that-i-dont-want-to-appear will give me the expected result…

Can i use WPAS to search by name and not by slug?

Code:

function cautare_mica() {
        $args = array();

        if(isset($_COOKIE['carsno'])) {
            $ppage = $_COOKIE['carsno'];
        }
        else{
            $ppage = 24;
        }

        $args['wp_query'] = array('post_type' => 'autoturism',
            'posts_per_page' => $ppage,
            'order' => 'DESC',
            'orderby' => 'post_date',
            'category__not_in' => array( 83, 84 ),
            );

        $args['form'] = array(
            'disable_wrappers' => true,
            'action' => get_bloginfo('url') . '/masini-second-hand'
            );



        $args['fields'][] = array('type' => 'taxonomy',
            'taxonomy' => 'leasing-auto',
            'format' => 'text',
            'operator' => 'IN',
            'compare' => 'LIKE',
            'placeholder' => 'Exemplu : BMW 320',
            'pre_html' => '<div class="input-group">',
            'class' => 'form-control input-lg',
            'post_html' => '',
            'term_args' => array('hide_empty' => true, 
                'orderby' => 'name', 
                'order' => 'ASC')
            );


        $args['fields'][] = array( 'type' => 'submit', 
            'value' => 'Cauta',
            'pre_html' => '<span class="input-group-btn">',
            'class' => 'btn btn-primary btn-lg',
            'post_html' => '</span></div>',
            );


        register_wpas_form('minisearch', $args); 
    }


    add_action('init', 'cautare_mica');

Read more here: WPAS wordpress search


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: