Link to home
Start Free TrialLog in
Avatar of Jon Imms
Jon ImmsFlag for United States of America

asked on

Help with WP Job Manager Single post template.

Hello,  I am having problems with a WordPress plugin call WP-Job Manager, particularly trying to create a custom template for single jobs.

I have customized the default template by copying "content-job_listing.php"  from the plugin directory to  /themes/enfold/job_manager/content-job_listing.php. This works great, and is my template for all jobs. See code below.

<?php
/**
 * Single job listing.
 *
 * This template can be overridden by copying it to yourtheme/job_manager/content-single-job_listing.php.
 *
 * @see         https://wpjobmanager.com/document/template-overrides/
 * @author      Automattic
 * @package     WP Job Manager
 * @category    Template
 * @since       1.0.0
 * @version     1.28.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

?>
<div class="single_job_listing">
	
	<h2><?php the_title(); ?></h2>
		
	<div class="hide_above_mobile">
		<?php display_job_phonenumber_data(); ?>
	</div>
	
	<?php if ( $apply = get_the_job_application_method() ) :
		if ( $apply->type === 'url' ) {
	    	$application_href = $apply->url;
		} elseif ( $apply->type === 'email' ) {
	    	$application_href = sprintf( 'mailto:%1$s%2$s', $apply->email, '?subject=' . rawurlencode( $apply->subject )  );
		}
	?>
	
	<div class="application">
		<a class="application_button button" href="<?php echo $application_href; ?>" target="_blank"><?php _e( 'Apply for job', 'wp-job-manager' ); ?></a>
	</div>

	<?php endif; ?>

	<?php the_content() ?>
	<?php the_field('job_main_content'); ?>
	
	<?php if ( $apply = get_the_job_application_method() ) :
		if ( $apply->type === 'url' ) {
	    	$application_href = $apply->url;
		} elseif ( $apply->type === 'email' ) {
	    	$application_href = sprintf( 'mailto:%1$s%2$s', $apply->email, '?subject=' . rawurlencode( $apply->subject )  );
		}
	?>
	
	<div class="application">
		<a class="application_button button" href="<?php echo $application_href; ?>"><?php _e( 'Apply for job', 'wp-job-manager' ); ?></a>
	</div>
	<?php endif; ?>

	<div class="hide_above_mobile">
		<?php display_job_phonenumber_data(); ?></div>
	</div>

</div>

Open in new window


So for the new template, which I want for select jobs, I did this.

/themes/enfold/content-single-job_listing-big-6.php
<?php
/**
 * 
 * Template Name: Big 6 Layout
 * Template Post Type: job_listing
 */

	if ( !defined('ABSPATH') ){ die(); }
	
	global $avia_config;

	/*
	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
	 */
	 get_header();


 	 if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title();
 	 
 	 do_action( 'ava_after_main_title' );
	 ?>

		<div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>

			<div class='container'>

				<main class='template-page content  <?php avia_layout_class( 'content' ); ?> units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'job_listing'));?>>

                    <?php
                    /* Run the loop to output the posts.
                    * If you want to overload this in a child theme then include a file
                    * called loop-page.php and that will be used instead.
                    */

                    $avia_config['size'] = avia_layout_class( 'main' , false) == 'entry_without_sidebar' ? '' : 'entry_with_sidebar';
                    get_template_part( 'includes/loop', 'big6' );
                    ?>

                <!--end content-->
				</main>


			</div><!--end container-->

		</div><!-- close default .container_wrap element -->


 	<!-- REALLY stop The Loop. -->
<?php get_footer(); ?>


/themes/enfold/includes/loop-big6.php
<?php
global $avia_config, $post_loop_count;

$post_loop_count= 1;
$post_class 	= "post-entry-".avia_get_the_id();



// check if we got posts to display:
if (have_posts()) :

	while (have_posts()) : the_post();
?>

		<article class='post-entry post-entry-type-page <?php echo $post_class; ?>' <?php avia_markup_helper(array('context' => 'entry')); ?>>

			<div class="entry-content-wrapper clearfix">


					<?php the_content(); ?>
					<?php the_field('job_main_content'); ?>
	
	
					<br /><br />
					<?php display_job_phonenumber_data(); ?>

				
				<?php
           
				
				wp_link_pages($avia_wp_link_pages_args);

				if(has_tag() && is_single())
				{
					echo '<span class="blog-tags minor-meta">';
					the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> ');
					echo '</span></span>';
				}
                echo '</footer>';

				?>					
		</article><!--end post-entry-->


<?php
	$post_loop_count++;
	endwhile;
	else:
?>

    <article class="entry">
        <header class="entry-content-header">
            <h1 class='post-title entry-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1>
        </header>

        <?php get_template_part('includes/error404'); ?>

        <footer class="entry-footer"></footer>
    </article>

<?php

	endif;
?>

Open in new window


It works somewhat,  but it is also pulling from the /themes/enfold/job_manager/content-job_listing.php file.   So it's pulling this

<div class="single_job_listing">
	
	<h2><?php the_title(); ?></h2>
		
	<div class="hide_above_mobile">
		<?php display_job_phonenumber_data(); ?>
	</div>
	
	<?php if ( $apply = get_the_job_application_method() ) :
		if ( $apply->type === 'url' ) {
	    	$application_href = $apply->url;
		} elseif ( $apply->type === 'email' ) {
	    	$application_href = sprintf( 'mailto:%1$s%2$s', $apply->email, '?subject=' . rawurlencode( $apply->subject )  );
		}
	?>
	
	<div class="application">
		<a class="application_button button" href="<?php echo $application_href; ?>" target="_blank"><?php _e( 'Apply for job', 'wp-job-manager' ); ?></a>
	</div>

	<?php endif; ?>

	<?php the_content() ?>

Open in new window


so I'm needing to eliminate the post putting the title and apply for now button before everything.

here is the page  -- truck page
ASKER CERTIFIED SOLUTION
Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial