i want to ask something about wp-job-manager plugin. i have been already created a taxonomy_job_listing_categoy template to list all jobs from a certain job category. You can see an example here: http://www.jobseeker.gr/job-category/pliroforiki/

i have also added a custom search form ( keywords + location ) for more filtering. What i want now is when trying a search query on this custom search form to return the search results in the same page and not redirecting to the [jobs] page. Below is the template i have:

<?php get_header(); ?>

   <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
   <h1 class="page-title">Θέσεις εργασίας για <?php echo $term->name; ?></h1>

    <div id="content" role="main">
       <form  method="GET" action="">
        <input type="text"  placeholder="Λέξη κλειδί" id="search_keywords" name="search_keywords" />
        <input type="text"  placeholder="Τοποθεσία"   id="search_location" name="search_location" />
        <input class="search" type="submit"  value="Αναζήτηση" />
    <?php if ( ! dynamic_sidebar( 'Alert' ) ) : ?>
            <!--Wigitized 'Alert' for the home page -->
        <?php endif ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="job-listings">
                            <ul class="job_listings">
                              <?php global $post; ?>
                <li <?php job_listing_class(); ?> data-longitude="<?php echo esc_attr( $post->geolocation_lat ); ?>" data-latitude="<?php echo esc_attr( $post->geolocation_long ); ?>">
    <a href="<?php the_job_permalink(); ?>">
        <?php the_company_logo(); ?>
        <div class="position">
            <h3><?php the_title(); ?></h3>
            <div class="company">
                <?php the_company_name( '<strong>', '</strong> ' ); ?>
                <?php the_company_tagline( '<span class="tagline">', '</span>' ); ?>
        <div class="location">
            <?php the_job_location( false ); ?>
        <ul class="meta">
            <li class="job-type <?php echo get_the_job_type() ? sanitize_title( get_the_job_type()->slug ) : ''; ?>"><?php the_job_type(); ?></li>
            <li class="date"><date><?php printf( __( '%s πριν', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); ?></date></li>
                 <?php do_action( 'job_listing_meta_end' ); ?>
        <?php endwhile; else: ?>

            <div class="no-results">
                <p><strong><?php _e('There has been an error.'); ?></strong></p>
                <p><?php _e('We apologize for any inconvenience, please hit back on your browser or use the search form below.'); ?></p>
                <?php get_search_form(); /* outputs the default WordPress search form */ ?>
        <?php endif; ?>
              <?php the_posts_pagination( array( 'mid_size'  => 2 ) ); ?>

    </div><!-- #content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

The problem is that when searching there is no results returning. What am i missing?

Best Regards, Panos

  • Update info: After searching i come to this code: <form method="GET" action=""> <div class="job_category_search_keywords"> <input type="text" name="search_keywords" id="job_category_search_keywords" placeholder="Λέξη κλειδί, τίτλος ή εταιρεία" value="<?php echo esc_attr( $keywords ); ?>" /> <button type="submit" class="job-category">Αναζήτηση</button> <div class="clear"></div> </div> </form> <?php echo do_shortcode('[jobs categories='.get_query_var('job_listing_category').' show_filters="false"]'); ?> – Panos Jul 7 '16 at 10:56
  • You can see after the update an ex. jobseeker.gr/job-category/pliroforiki This is working fine. Two things only. The first is that the search query is not saving after submit button. The second the reset link is missing. I think is has to do with the ajax filters. Any help is welcome. – Panos Jul 7 '16 at 11:00
  • Please, use the edit link below the question to add additional info. Not everyone reads comments and they will be cleaned up. – kaiser Jul 7 '16 at 17:20

This is the finally code that is working like a chram

     $taxonomy = get_taxonomy( get_queried_object()->taxonomy );
     $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
     get_header(); ?>

     <h1 class="page-title">Θέσεις εργασίας για <?php echo $term->name; ?></h1>
        <div id="content">
       <article id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>

       <?php echo do_shortcode('[jobs categories='.get_query_var('job_listing_category').' show_filters="true"]'); ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>
  • Why don't you use the callback that is attached to the shortcode instead? Works faster (no Regex involved) and is closer to the real API. Also: Please use English instead of foreign languages so everyone can read and understand your example. – kaiser Jul 7 '16 at 12:51
  • @kaiser thank you for your comment. I don't know how to use the callback ( i am new to action hooks ) that's why. If you could provide this solution please you welcome to do it. I would happy to learn. I am sorry for the Greek's i have just forgotten translate to English. – Panos Jul 7 '16 at 15:31
  • You need to search up the add_shortcode() call in the plugin or theme that added it. The first argument is the shortcode name (that should be jobs) and the second argument is the callback. You can then simply use the callback directly. About the Greek: You can always edit questions and answers. It will be accepted asap (with more reputation points, you do not need review anymore). Just write a meaningful edit note :) – kaiser Jul 7 '16 at 17:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.