• Resolved tkgnewseed

    (@tkgnewseed)


    As a newbie using WP Jobs Manager, I noticed that there a good number of shortcodes and code-snippets available. However, unless I missed something, I wanted to be able to add the job search form to any pages at any locations I need it at.

    In this case, I am using Espy Theme by WP Job Manager and instead of tampering with all the various templates it has, I decided to take the current Espy search form code from one of the templates, configure the coding so that it uses the [shortcode] capability and applied the code to functions.php and saved it to the Espy Child theme.

    Now I can go to any page or post and add the following shortcode where I want to display the search form: [job_search_form] You can even add this to your favorite page builder like Elementor.

    Here’s the code for the functions.php file. Enjoy!

    /**

    • EDK – Custom Independ Job Search Form with shortcode
      */
      function job_search_form_shortcode() {
      ob_start(); ?>
      ‘job_listing_category’,
      ‘hide_empty’ => false,
      )); $regions = get_terms(array( 'taxonomy' => 'job_listing_region', 'hide_empty' => false, )); $job_region = get_option('job_manager_regions_filter'); ?> <div class="search-filter-wrap"> <form class="form-inline" method="GET" action="<?php echo job_manager_get_permalink('jobs'); ?>"> <div class="filter-inputwrap"> <div class="form-group"> <label class="sr-only" for="search_keywords"><?php _e('Job Titles, Keywords, Phrase', 'espy-jobs'); ?></label> <input type="text" name="search_keywords" class="form-control" id="search-keywords" placeholder="<?php esc_attr_e('Job Titles, Keywords, Phrase', 'espy-jobs'); ?>"> </div> <?php if ($job_region == '1') : ?> <?php if (!empty($regions) && !is_wp_error($regions)) : ?> <div class="form-group"> <label class="sr-only" for="search_region"><?php _e('Job Region', 'espy-jobs') ?></label> <select class="form-control" id="job-region" name="search_region"> <option><?php _e('All Regions', 'espy-jobs') ?></option> <?php foreach ($regions as $r) : echo '<option value="' . $r->term_id . '">' . $r->name . '</option>'; endforeach; ?> </select> </div> <?php endif; ?> <?php else : ?> <div class="form-group"> <label class="sr-only" for="search_location"><?php _e('All Location', 'espy-jobs') ?></label> <input type="text" name="search_location" class="form-control" id="search-location" placeholder="All Location"> </div> <?php endif; ?> &lt;div class="form-group"&gt; &lt;button type="submit" class="btn btn-primary"&gt;Search&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt;</div> <?php
      return ob_get_clean();
      }

    add_shortcode(‘job_search_form’, ‘job_search_form_shortcode’);

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Job Search Form Anywhere!’ is closed to new replies.