List Multiple Job Types
-
I had this need for a client and see that others wanted the same so I created these additional functions. Hopefully these can be included in the core.
Add the following to your child theme functions.php:
/** * get_the_job_types function. */ function get_the_job_types( $post = null ) { $post = get_post( $post ); if ( $post->post_type !== 'job_listing' ) { return; } $types = wp_get_post_terms( $post->ID, 'job_listing_type' ); return apply_filters( 'the_job_types', $types, $post); } /** * print_job_types function. */ function print_job_types( $post = null ) { $types = get_the_job_types( $post ); foreach( $types as $type ) { echo '<li class="job-type '. sanitize_title( $type->slug ).'">'. $type->name.'</li>'; } }
create a template override on the content-job_listing.php file and change this line:
<li class="job-type <?php echo get_the_job_type() ? sanitize_title( get_the_job_type()->slug ) : ''; ?>"><?php the_job_type(); ?></li>
to this:
<?php print_job_types(); ?>
You may have to create additional template overrides for the single job details page or if your theme has specific styling overirde already.
Hope this helps.
- The topic ‘List Multiple Job Types’ is closed to new replies.