WP Job Manager Shortcodes

Below, you’ll find a detailed guide on how to add the WP Job Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP Job Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WP Job Manager Plugin and the shortcodes it provides:

Plugin Icon
WP Job Manager

"WP Job Manager is a lightweight plugin for adding job-board functionality to your WordPress site. It's user-friendly, extensible, and allows you to manage job listings with ease."

★★★★✩ (229) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [submit_job_form]
  • [job_dashboard]
  • [jobs]
  • [job]
  • [job_summary]
  • [job_apply]

WP Job Manager [submit_job_form] Shortcode

The WP Job Manager shortcode, ‘submit_job_form’, enables users to display a job submission form on their website. This form is retrieved from the global ‘job_manager’ object. This shortcode simplifies the process of job listing by users, enhancing the user experience on job listing sites.

Shortcode: [submit_job_form]

Examples and Usage

Basic example – Utilizes the shortcode to display the job submission form without any additional attributes.

[submit_job_form /]

Advanced examples

Display the job submission form with a specific job ID. This will pre-fill the form with the details of the job with the given ID, if it exists.

[submit_job_form job_id=123 /]

Display the job submission form with a specific job type. This will filter the job types dropdown in the form to only show the specified type.

[submit_job_form job_type="full-time" /]

Display the job submission form with a specific job category. This will filter the job categories dropdown in the form to only show the specified category.

[submit_job_form job_category="engineering" /]

Display the job submission form with a specific job type and job category. This will filter both the job types and job categories dropdowns in the form to only show the specified type and category.

[submit_job_form job_type="full-time" job_category="engineering" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [submit_job_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'submit_job_form', [ $this, 'submit_job_form' ] );

Shortcode PHP function:

function submit_job_form( $atts = [] ) {
		return $GLOBALS['job_manager']->forms->get_form( 'submit-job', $atts );
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

WP Job Manager [job_dashboard] Shortcode

The WP Job Manager plugin shortcode ‘job_dashboard’ is used to display a user’s job dashboard. It checks if a user is logged in and shows the job dashboard or login page accordingly. The shortcode also accepts an ‘action’ parameter. If provided, it triggers a related action or displays the job dashboard. It fetches job data, prepares job actions, and renders the ‘job-dashboard.php’ template.

Shortcode: [job_dashboard]

Examples and Usage

Basic example – Showcases the use of the ‘job_dashboard’ shortcode without any additional parameters. This will display the job dashboard with default settings.

[job_dashboard /]

Advanced examples

Displays the job dashboard with a custom number of jobs per page. In this example, the job dashboard will display 10 jobs per page.

[job_dashboard posts_per_page="10" /]

Allows you to execute a specific action on the job dashboard. The action will be executed if a plugin wants to show alternative content. In this example, the ‘delete’ action is specified.

[job_dashboard action="delete" /]

Combines multiple parameters to customize the job dashboard further. In this example, the job dashboard will display 20 jobs per page and execute the ‘edit’ action.

[job_dashboard posts_per_page="20" action="edit" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [job_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'job_dashboard', [ $this, 'job_dashboard' ] );

Shortcode PHP function:

function job_dashboard( $atts ) {
		if ( ! is_user_logged_in() ) {
			ob_start();
			get_job_manager_template( 'job-dashboard-login.php' );
			return ob_get_clean();
		}

		$new_atts       = shortcode_atts(
			[
				'posts_per_page' => '25',
			],
			$atts
		);
		$posts_per_page = $new_atts['posts_per_page'];

		wp_enqueue_script( 'wp-job-manager-job-dashboard' );

		ob_start();

		// If doing an action, show conditional content if needed....
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Input is used safely.
		$action = isset( $_REQUEST['action'] ) ? sanitize_title( wp_unslash( $_REQUEST['action'] ) ) : false;
		if ( ! empty( $action ) ) {
			// Show alternative content if a plugin wants to.
			if ( has_action( 'job_manager_job_dashboard_content_' . $action ) ) {
				do_action( 'job_manager_job_dashboard_content_' . $action, $atts );

				return ob_get_clean();
			}
		}

		// ....If not show the job dashboard.
		$jobs = new WP_Query( $this->get_job_dashboard_query_args( $posts_per_page ) );

		// Cache IDs for access check later on.
		$this->job_dashboard_job_ids = wp_list_pluck( $jobs->posts, 'ID' );

		echo wp_kses_post( $this->job_dashboard_message );

		$job_dashboard_columns = apply_filters(
			'job_manager_job_dashboard_columns',
			[
				'job_title' => __( 'Title', 'wp-job-manager' ),
				'filled'    => __( 'Filled?', 'wp-job-manager' ),
				'date'      => __( 'Date Posted', 'wp-job-manager' ),
				'expires'   => __( 'Listing Expires', 'wp-job-manager' ),
			]
		);

		$job_actions = [];
		foreach ( $jobs->posts as $job ) {
			$job_actions[ $job->ID ] = $this->get_job_actions( $job );
		}

		get_job_manager_template(
			'job-dashboard.php',
			[
				'jobs'                  => $jobs->posts,
				'job_actions'           => $job_actions,
				'max_num_pages'         => $jobs->max_num_pages,
				'job_dashboard_columns' => $job_dashboard_columns,
			]
		);

		return ob_get_clean();
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

WP Job Manager [jobs] Shortcode

The WP Job Manager shortcode is a powerful tool that outputs job listings on your WordPress site. It allows customization of job listings with filters like location, keywords, categories, and job types.

Shortcode: [jobs]

Parameters

Here is a list of all possible jobs shortcode parameters and attributes:

  • per_page – Number of job listings to display per page.
  • orderby – The criteria to order job listings by.
  • order – The order to display job listings, Ascending or Descending.
  • show_filters – Whether to display job filters or not.
  • show_categories – Whether to display job categories or not.
  • show_category_multiselect – Whether to allow multi-selection of job categories.
  • show_pagination – Whether to display pagination or not.
  • show_more – Whether to display a “Load More” button or not.
  • categories – Specific job categories to display.
  • job_types – Specific job types to display.
  • post_status – The status of the job listings to display.
  • featured – Whether to show only featured jobs or not.
  • filled – Whether to show only filled jobs or not.
  • remote_position – Whether to show only remote jobs or not.
  • location – The location of the job listings to display.
  • keywords – Keywords to filter the job listings by.
  • selected_category – The selected job category to display.
  • selected_job_types – The selected job types to display.

Examples and Usage

Basic example – Displaying job listings using the default settings.

[jobs /]

Advanced examples

Displaying job listings where the filters are hidden, sorted by the ‘date’ field in ascending order, and only showing 5 listings per page.

[jobs show_filters=false orderby='date' order='ASC' per_page=5 /]

Displaying job listings where only the ‘remote’ positions are shown, with the results being paginated and the category multiselect feature being enabled.

[jobs remote_position=true show_pagination=true show_category_multiselect=true /]

Displaying job listings that are from a specific category (using the category’s ID or slug), and only showing the ‘filled’ positions.

[jobs categories='developer' filled=true /]

PHP Function Code

In case you have difficulties debugging what causing issues with [jobs] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'jobs', [ $this, 'output_jobs' ] );

Shortcode PHP function:

function output_jobs( $atts ) {
		ob_start();

		if ( ! job_manager_user_can_browse_job_listings() ) {
			get_job_manager_template_part( 'access-denied', 'browse-job_listings' );
			return ob_get_clean();
		}

		$atts = shortcode_atts(
			apply_filters(
				'job_manager_output_jobs_defaults',
				[
					'per_page'                  => get_option( 'job_manager_per_page' ),
					'orderby'                   => 'featured',
					'order'                     => 'DESC',

					// Filters + cats.
					'show_filters'              => true,
					'show_categories'           => true,
					'show_category_multiselect' => get_option( 'job_manager_enable_default_category_multiselect', false ),
					'show_pagination'           => 'pagination' === get_option( 'job_manager_job_listing_pagination_type' ) ? true : false,
					'show_more'                 => 'load_more' === get_option( 'job_manager_job_listing_pagination_type' ) ? true : false,

					// Limit what jobs are shown based on category, post status, and type.
					'categories'                => '',
					'job_types'                 => '',
					'post_status'               => '',
					'featured'                  => null, // True to show only featured, false to hide featured, leave null to show both.
					'filled'                    => null, // True to show only filled, false to hide filled, leave null to show both/use the settings.
					'remote_position'           => null, // True to show only remote, false to hide remote, leave null to show both.

					// Default values for filters.
					'location'                  => '',
					'keywords'                  => '',
					'selected_category'         => '',
					'selected_job_types'        => implode( ',', array_values( get_job_listing_types( 'id=>slug' ) ) ),
				]
			),
			$atts
		);

		if ( ! get_option( 'job_manager_enable_categories' ) ) {
			$atts['show_categories'] = false;
		}

		// String and bool handling.
		$atts['show_filters']              = $this->string_to_bool( $atts['show_filters'] );
		$atts['show_categories']           = $this->string_to_bool( $atts['show_categories'] );
		$atts['show_category_multiselect'] = $this->string_to_bool( $atts['show_category_multiselect'] );
		$atts['show_more']                 = $this->string_to_bool( $atts['show_more'] );
		$atts['show_pagination']           = $this->string_to_bool( $atts['show_pagination'] );

		if ( ! is_null( $atts['featured'] ) ) {
			$atts['featured'] = ( is_bool( $atts['featured'] ) && $atts['featured'] ) || in_array( $atts['featured'], [ 1, '1', 'true', 'yes' ], true );
		}

		if ( ! is_null( $atts['filled'] ) ) {
			$atts['filled'] = ( is_bool( $atts['filled'] ) && $atts['filled'] ) || in_array( $atts['filled'], [ 1, '1', 'true', 'yes' ], true );
		}

		if ( ! is_null( $atts['remote_position'] ) ) {
			$atts['remote_position'] = ( is_bool( $atts['remote_position'] ) && $atts['remote_position'] ) || in_array( $atts['remote_position'], [ 1, '1', 'true', 'yes' ], true );
		}

		// By default, use client-side state to populate form fields.
		$disable_client_state = false;

		// Get keywords, location, category and type from querystring if set.
		// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Input is used safely.
		if ( ! empty( $_GET['search_keywords'] ) ) {
			$atts['keywords']     = sanitize_text_field( wp_unslash( $_GET['search_keywords'] ) );
			$disable_client_state = true;
		}
		if ( ! empty( $_GET['search_location'] ) ) {
			$atts['location']     = sanitize_text_field( wp_unslash( $_GET['search_location'] ) );
			$disable_client_state = true;
		}
		if ( ! empty( $_GET['search_category'] ) ) {
			$atts['selected_category'] = sanitize_text_field( wp_unslash( $_GET['search_category'] ) );
			$disable_client_state      = true;
		}
		if ( ! empty( $_GET['search_job_type'] ) ) {
			$atts['selected_job_types'] = sanitize_text_field( wp_unslash( $_GET['search_job_type'] ) );
			$disable_client_state       = true;
		}
		// phpcs:enable WordPress.Security.NonceVerification.Recommended

		// Array handling.
		$atts['categories']         = is_array( $atts['categories'] ) ? $atts['categories'] : array_filter( array_map( 'trim', explode( ',', $atts['categories'] ) ) );
		$atts['selected_category']  = is_array( $atts['selected_category'] ) ? $atts['selected_category'] : array_filter( array_map( 'trim', explode( ',', $atts['selected_category'] ) ) );
		$atts['job_types']          = is_array( $atts['job_types'] ) ? $atts['job_types'] : array_filter( array_map( 'trim', explode( ',', $atts['job_types'] ) ) );
		$atts['post_status']        = is_array( $atts['post_status'] ) ? $atts['post_status'] : array_filter( array_map( 'trim', explode( ',', $atts['post_status'] ) ) );
		$atts['selected_job_types'] = is_array( $atts['selected_job_types'] ) ? $atts['selected_job_types'] : array_filter( array_map( 'trim', explode( ',', $atts['selected_job_types'] ) ) );

		// Normalize field for categories.
		if ( ! empty( $atts['selected_category'] ) ) {
			foreach ( $atts['selected_category'] as $cat_index => $category ) {
				if ( ! is_numeric( $category ) ) {
					$term = get_term_by( 'slug', $category, 'job_listing_category' );

					if ( $term ) {
						$atts['selected_category'][ $cat_index ] = $term->term_id;
					}
				}
			}
		}

		$data_attributes = [
			'location'                   => $atts['location'],
			'keywords'                   => $atts['keywords'],
			'show_filters'               => $atts['show_filters'] ? 'true' : 'false',
			'show_pagination'            => $atts['show_pagination'] ? 'true' : 'false',
			'per_page'                   => $atts['per_page'],
			'orderby'                    => $atts['orderby'],
			'order'                      => $atts['order'],
			'categories'                 => implode( ',', $atts['categories'] ),
			'disable-form-state-storage' => $disable_client_state,
		];

		if ( $atts['show_filters'] ) {
			get_job_manager_template(
				'job-filters.php',
				[
					'per_page'                  => $atts['per_page'],
					'orderby'                   => $atts['orderby'],
					'order'                     => $atts['order'],
					'show_categories'           => $atts['show_categories'],
					'categories'                => $atts['categories'],
					'selected_category'         => $atts['selected_category'],
					'job_types'                 => $atts['job_types'],
					'atts'                      => $atts,
					'location'                  => $atts['location'],
					'remote_position'           => $atts['remote_position'],
					'keywords'                  => $atts['keywords'],
					'selected_job_types'        => $atts['selected_job_types'],
					'show_category_multiselect' => $atts['show_category_multiselect'],
				]
			);

			get_job_manager_template( 'job-listings-start.php' );
			get_job_manager_template( 'job-listings-end.php' );

			if ( ! $atts['show_pagination'] && $atts['show_more'] ) {
				echo '<a class="load_more_jobs" href="#" style="display:none;"><strong>' . esc_html__( 'Load more listings', 'wp-job-manager' ) . '</strong></a>';
			}
		} else {
			$jobs = get_job_listings(
				apply_filters(
					'job_manager_output_jobs_args',
					[
						'search_location'   => $atts['location'],
						'search_keywords'   => $atts['keywords'],
						'post_status'       => $atts['post_status'],
						'search_categories' => $atts['categories'],
						'job_types'         => $atts['job_types'],
						'orderby'           => $atts['orderby'],
						'order'             => $atts['order'],
						'posts_per_page'    => $atts['per_page'],
						'featured'          => $atts['featured'],
						'filled'            => $atts['filled'],
						'remote_position'   => $atts['remote_position'],
					]
				)
			);

			if ( ! empty( $atts['job_types'] ) ) {
				$data_attributes['job_types'] = implode( ',', $atts['job_types'] );
			}

			if ( $jobs->have_posts() ) {
				get_job_manager_template( 'job-listings-start.php' );
				while ( $jobs->have_posts() ) {
					$jobs->the_post();
					get_job_manager_template_part( 'content', 'job_listing' );
				}
				get_job_manager_template( 'job-listings-end.php' );
				if ( $jobs->found_posts > $atts['per_page'] && $atts['show_more'] ) {
					wp_enqueue_script( 'wp-job-manager-ajax-filters' );
					if ( $atts['show_pagination'] ) {
						// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Template output.
						echo get_job_listing_pagination( $jobs->max_num_pages );
					} else {
						echo '<a class="load_more_jobs" href="#"><strong>' . esc_html__( 'Load more listings', 'wp-job-manager' ) . '</strong></a>';
					}
				}
			} else {
				do_action( 'job_manager_output_jobs_no_results' );
			}
			wp_reset_postdata();
		}

		$data_attributes_string = '';
		if ( ! is_null( $atts['featured'] ) ) {
			$data_attributes['featured'] = $atts['featured'] ? 'true' : 'false';
		}
		if ( ! is_null( $atts['filled'] ) ) {
			$data_attributes['filled'] = $atts['filled'] ? 'true' : 'false';
		}
		if ( ! is_null( $atts['remote_position'] ) ) {
			$data_attributes['remote_position'] = $atts['remote_position'] ? 'true' : 'false';
		}
		if ( ! empty( $atts['post_status'] ) ) {
			$data_attributes['post_status'] = implode( ',', $atts['post_status'] );
		}

		$data_attributes['post_id'] = isset( $GLOBALS['post'] ) ? $GLOBALS['post']->ID : 0;

		/**
		 * Pass additional data to the job listings <div> wrapper.
		 *
		 * @since 1.34.0
		 *
		 * @param array $data_attributes {
		 *     Key => Value array of data attributes to pass.
		 *
		 *     @type string $$key Value to pass as a data attribute.
		 * }
		 * @param array $atts            Attributes for the shortcode.
		 */
		$data_attributes = apply_filters( 'job_manager_jobs_shortcode_data_attributes', $data_attributes, $atts );

		foreach ( $data_attributes as $key => $value ) {
			$data_attributes_string .= 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
		}

		$job_listings_output = apply_filters( 'job_manager_job_listings_output', ob_get_clean() );

		return '<div class="job_listings" ' . $data_attributes_string . '>' . $job_listings_output . '</div>';
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

WP Job Manager [job] Shortcode

The WP Job Manager plugin shortcode ‘job’ is used to display specific job listings. It accepts an ‘id’ attribute that corresponds to the ID of the job listing. If no ‘id’ is provided, the function returns null. It then creates a new WP_Query object to fetch the job listing details. The shortcode outputs the job title and content in a div with classes ‘job_shortcode’ and ‘single_job_listing’. If there are multiple posts, it loops through all of them, displaying each one individually.

Shortcode: [job]

Parameters

Here is a list of all possible job shortcode parameters and attributes:

  • id – Specifies the unique identifier of the job listing.

Examples and Usage

Basic example – Display a specific job listing by referencing its ID.

[job id=123 /]

Advanced examples

Display a job listing by referencing its ID, and also customize the output by adding additional HTML elements and CSS classes. In this case, the job listing will be wrapped in a div with the class “my_custom_class”.

[job id=123 class="my_custom_class" /]

Note: The second example assumes that you have modified the ‘output_job’ function to accept and handle a ‘class’ attribute. If you haven’t done this, the ‘class’ attribute will be ignored.

PHP Function Code

In case you have difficulties debugging what causing issues with [job] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'job', [ $this, 'output_job' ] );

Shortcode PHP function:

function output_job( $atts ) {
		$atts = shortcode_atts(
			[
				'id' => '',
			],
			$atts
		);

		if ( ! $atts['id'] ) {
			return null;
		}

		ob_start();

		$args = [
			'post_type'   => 'job_listing',
			'post_status' => 'publish',
			'p'           => $atts['id'],
		];

		$jobs = new WP_Query( $args );

		if ( $jobs->have_posts() ) {
			while ( $jobs->have_posts() ) {
				$jobs->the_post();
				echo '<h1>' . wp_kses_post( wpjm_get_the_job_title() ) . '</h1>';
				get_job_manager_template_part( 'content-single', 'job_listing' );
			}
		}

		wp_reset_postdata();

		return '<div class="job_shortcode single_job_listing">' . ob_get_clean() . '</div>';
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

WP Job Manager [job_summary] Shortcode

The WP-Job-Manager shortcode ‘job_summary’ displays a random job listing summary. It can be customized with attributes like ‘id’, ‘width’, ‘align’, ‘featured’, and ‘limit’. This shortcode fetches job posts, and if an ‘id’ is provided, it fetches that specific job. The ‘featured’ attribute filters featured jobs. If left null, it shows all jobs.

Shortcode: [job_summary]

Parameters

Here is a list of all possible job_summary shortcode parameters and attributes:

  • id – Identifier for a specific job listing
  • width – Specifies the width of the job summary
  • align – Decides the alignment of the job summary
  • featured – Filters job listings to show featured, hide featured, or show both
  • limit – Determines how many job listings are displayed

Examples and Usage

Basic example – Displays a single job listing randomly selected from the published listings.

[job_summary limit=1 /]

Advanced examples

Display a specific job listing by referencing its ID. The job listing will be shown with a width of 300px and aligned to the right.

[job_summary id=3 width="300px" align="right" /]

Display 3 job listings randomly selected from the published listings. Only featured job listings will be considered for display. The job listings will be shown with a width of 250px and aligned to the left.

[job_summary limit=3 featured=true width="250px" align="left" /]

Display a single job listing randomly selected from the published listings. The job listing will not be a featured listing. The job listing will be shown with a width of 200px and aligned to the center.

[job_summary limit=1 featured=false width="200px" align="center" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [job_summary] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'job_summary', [ $this, 'output_job_summary' ] );

Shortcode PHP function:

function output_job_summary( $atts ) {
		$atts = shortcode_atts(
			[
				'id'       => '',
				'width'    => '250px',
				'align'    => 'left',
				'featured' => null, // True to show only featured, false to hide featured, leave null to show both (when leaving out id).
				'limit'    => 1,
			],
			$atts
		);

		ob_start();

		$args = [
			'post_type'   => 'job_listing',
			'post_status' => 'publish',
		];

		if ( ! $atts['id'] ) {
			$args['posts_per_page'] = $atts['limit'];
			$args['orderby']        = 'rand';
			if ( ! is_null( $atts['featured'] ) ) {
				// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Query results are limited.
				$args['meta_query'] = [
					[
						'key'     => '_featured',
						'value'   => '1',
						'compare' => $atts['featured'] ? '=' : '!=',
					],
				];
			}
		} else {
			$args['p'] = absint( $atts['id'] );
		}

		$jobs = new WP_Query( $args );

		if ( $jobs->have_posts() ) {
			while ( $jobs->have_posts() ) {
				$jobs->the_post();
				$width = $atts['width'] ? $atts['width'] : 'auto';
				echo '<div class="job_summary_shortcode align' . esc_attr( $atts['align'] ) . '" style="width: ' . esc_attr( $width ) . '">';
				get_job_manager_template_part( 'content-summary', 'job_listing' );
				echo '</div>';
			}
		}

		wp_reset_postdata();

		return ob_get_clean();
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

WP Job Manager [job_apply] Shortcode

The WP Job Manager shortcode ‘job_apply’ manages job application processes. It queries for job listings and outputs application methods. This shortcode retrieves specific job listings based on the given ‘id’. If no ‘id’ is provided, it returns an empty string. If valid, it initiates a WP_Query for the job listing, and if the post exists, it retrieves the application method. It then triggers actions before and after job application, displaying the application details within a div wrapper.

Shortcode: [job_apply]

Parameters

Here is a list of all possible job_apply shortcode parameters and attributes:

  • id – The unique ID number of the job listing

Examples and Usage

Basic example – Utilizing the shortcode to display the job application method for a specific job listing by referencing its ID.

[job_apply id=123 /]

Advanced examples

Modifying the shortcode to display the job application method for multiple job listings by referencing their IDs. The IDs are separated by commas. This can be useful when you want to highlight specific job listings.

[job_apply id="123,456,789" /]

In this example, the shortcode is used within a loop to display the job application method for all published job listings. This can be useful when you want to create a page that showcases all available jobs and their respective application methods.


<?php
$jobs = get_posts( array(
    'post_type' => 'job_listing',
    'post_status' => 'publish'
) );

foreach ( $jobs as $job ) {
    echo do_shortcode( '[job_apply id="' . $job->ID . '" /]' );
}
?>

PHP Function Code

In case you have difficulties debugging what causing issues with [job_apply] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'job_apply', [ $this, 'output_job_apply' ] );

Shortcode PHP function:

function output_job_apply( $atts ) {
		$new_atts = shortcode_atts(
			[
				'id' => '',
			],
			$atts
		);
		$id       = $new_atts['id'];

		ob_start();

		$args = [
			'post_type'   => 'job_listing',
			'post_status' => 'publish',
		];

		if ( ! $id ) {
			return '';
		} else {
			$args['p'] = absint( $id );
		}

		$jobs = new WP_Query( $args );

		if ( $jobs->have_posts() ) {
			while ( $jobs->have_posts() ) {
				$jobs->the_post();
				$apply = get_the_job_application_method();
				do_action( 'job_manager_before_job_apply_' . absint( $id ) );
				if ( apply_filters( 'job_manager_show_job_apply_' . absint( $id ), true ) ) {
					echo '<div class="job-manager-application-wrapper">';
					do_action( 'job_manager_application_details_' . $apply->type, $apply );
					echo '</div>';
				}
				do_action( 'job_manager_after_job_apply_' . absint( $id ) );
			}
			wp_reset_postdata();
		}

		return ob_get_clean();
	}

Code file location:

wp-job-manager/wp-job-manager/includes/class-wp-job-manager-shortcodes.php

Conclusion

Now that you’ve learned how to embed the WP Job Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *