Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    Can you explain what you are trying to do? Have a search on the [jobs] shortcode?

    Thread Starter nhobaby

    (@nhobaby)

    I have add new field:

    function frontend_add_sex_field( $fields ) {
      $fields['job']['f_sex'] = array(
        'label' => __( 'Sex', 'job_manager' ),
        'type' => 'select',
        'required' => false,
        'options' => array( 'none'	=> 'Don't care',
    			'male' 	=> 'Male',
    			'female'=> 'Female',),
        'priority' => 15
      );
    }
    add_filter( 'submit_job_form_fields', 'frontend_add_sex_field' );

    I use the [jobs] shortcode in page: https://localhost/job/search/

    Search form:

    <form method="GET" action="/job/search/">
    <p>
    <label for="keywords">Keywords</label>
    <input type="text" id="search_keywords" name="search_keywords" />
    </p>
    <p>
    <label for="keywords">Location</label>
    <input type="text" id="search_location" name="search_location" />
    </p>
    <p>
    <label for="keywords">Sex</label>
    <input type="text" id="search_sex" name="search_sex" />
    </p>
    <p>
    <input type="submit" value="Search" />
    </p>
    </form>

    How it work?

    Plugin Author Mike Jolley

    (@mikejolley)

    It won’t work on its own because the code doesn’t know to look for ‘search_sex’.

    You’d need two extra functions hooked in.

    One here to get the value of search_sex and pass it through to get_job_listings https://github.com/mikejolley/WP-Job-Manager/blob/master/includes/class-wp-job-manager-ajax.php#L53

    And another here to manipulate the query https://github.com/mikejolley/WP-Job-Manager/blob/master/wp-job-manager-functions.php#L134

    Thread Starter nhobaby

    (@nhobaby)

    Thank you so much!

    hello. would this work with a drop down as well?

    I’m trying to make astoundify’s job regions to work this way but it doesn’t.

    So maybe an approach like this one would be great.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to search custom field?’ is closed to new replies.