gistfile1.phtml<?php function custom_listify_single_job_listing_actions_after() { global $post; $url = get_post_meta( $post->ID, ‘_company_website’, true ); $offerta_url = get_post_meta( $post->ID, ‘_company_offerta’, true ); if( $offerta_url ) echo "<a href="" . esc_url( $url ) . "" class="button" target="_blank">VAI ALL ‘OFFERTA</a>"; echo ‘<a href="’ . esc_url( $url ) . ‘" class="button" target="_blank">Vai al sito</a>’; } add_filter( ‘listify_single_job_listing_actions_after’, ‘custom_listify_single_job_listing_actions_after’ );
Only display field and label if value exists
formatted.php<?php $company_description = get_company_field( ‘company_description’ ); if( $company_description ): ?> <h4><?php _e( ‘About Us’, ‘petsitter’ ); ?></h4> <?php echo $company_description; endif; ?> minimal.php<?php $company_description = get_company_field( ‘company_description’ ); if( $company_description ):?> <h4><?php _e( ‘About Us’, ‘petsitter’ ); ?></h4> <?php echo $company_description; endif; ?>
WCPL get_packages function update to support new WCPL filenames
wc.php/** * Get packages in Field Editor format * * * @since 1.2.2 * * @param bool $as_array * * @return array|string */ static function get_packages( $as_array = FALSE ) { $fpackages = array(); if( ! class_exists( ‘WP_Job_Manager_WCPL_Submit_Job_Form’ ) ) { if( ! defined( ‘JOB_MANAGER_WCPL_PLUGIN_DIR’ ) ) return false; $legacy_file = JOB_MANAGER_WCPL_PLUGIN_DIR . ‘/includes/class-wp-job-manager-wcpl-submit-job-form.php’; $new_file […]
Auto set phone field type flag by visitors IP, and set country(s) at top of list
functions.php<?php add_filter( ‘job_manager_field_editor_phone_args’, ‘my_custom_phone_args’ ); function my_custom_phone_args( $args ){ // Other available arguments, see GitHub for details // https://github.com/Bluefieldscom/intl-tel-input#options // // $args[‘allowExtensions’] = ‘false’; // $args[‘autoFormat’] = ‘true’; // $args[‘autoHideDialCode’] = ‘false’; // $args[‘autoPlaceholder’] = ‘true’; // $args[‘ipinfoToken’] = ”; // $args[‘nationalMode’] = ‘true’; $args[‘preferredCountries’] = array( ‘iq’ ); $args[‘defaultCountry’] = ‘auto’; return $args; }
Output multiple image thumbnails from multi-file upload
content-single-job_listing.php$images = get_custom_field( ‘job_multifile’ ); if ( is_array( $images ) && ! empty( $images ) ){ foreach( $images as $image ){ $thumbnail_id = get_attachment_id_from_url( $image ); $thumbnail = wp_get_attachment_thumb_url( $thumbnail_id ); echo "<a href="{$image}"><img src="{$thumbnail}"></a>"; } } elseif( ! empty( $images ) ){ $thumbnail_id = get_attachment_id_from_url( $images ); $thumbnail = wp_get_attachment_thumb_url( $thumbnail_id ); echo "<a […]
Get WordPress image attachment ID by URL
functions.php if( ! function_exists( ‘get_attachment_id_from_url’ ) ){ function get_attachment_id_from_url( $attachment_url = ” ) { global $wpdb; $attachment_id = FALSE; // If there is no url, return. if ( ” == $attachment_url ) return; // Get the upload directory paths $upload_dir_paths = wp_upload_dir(); // Make sure the upload path base directory exists in the attachment URL, […]
Custom validation for number with decimals
gistfile1.php<?php add_filter(‘submit_job_form_validate_fields’, ‘check_price_job_field’); function check_price_job_field( $has_error, $fields, $values ){ // Return true if this field doesn’t exist (to prevent errors if you dont have field created) if( ! isset( $values[‘job’][‘price’] ) ) return true; if( empty( $values[‘job’][‘price’] ) || ! is_float( $values[‘job’][‘price’] ) ){ throw new Exception( __( ‘The custom field value must be numerical […]
Output specific fields in a table
job-submit.php<?php /** * Job Submission Form */ if ( ! defined( ‘ABSPATH’ ) ) exit; global $job_manager; ?> <form action="<?php echo $action; ?>" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data"> <?php if ( apply_filters( ‘submit_job_form_show_signin’, true ) ) : ?> <?php get_job_manager_template( ‘account-signin.php’ ); ?> <?php endif; ?> <?php if ( job_manager_user_can_post_job() ) : ?> <!– Job Information […]
Get custom field arrays
gistfile1.php<?php $jmfe = WP_Job_Manager_Field_Editor_Fields::get_instance(); $job_fields = $jmfe->get_fields( ‘job’, ‘custom’ ); $company_fields = $jmfe->get_fields( ‘company’, ‘custom’ ); ?>
Only output field if it has a value
gistfile1.phtml<?php $some_field = get_job_field( ‘some_meta_key’ ); if( ! empty( $some_field ) ) { echo "<h3>Some Field:</h3>"; echo $some_field; } ?>