We help IT Professionals succeed at work.

Post ID array not working

Jon Imms
Jon Imms asked
on
92 Views
Last Modified: 2019-03-22
I am trying to modify my wp-job-manager template.  

I have an image, and a bit of HTML code I want to show only on certain jobs. I'm using the post-IDs but it's not working.  Basically, if the job is postID19672 then I want a different layout on top, then the rest of the template.  I'm just getting a white page at the moment.  

the page is here -- webpage

<?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
}

?>
<?php
	if( is_page( array('19672', '25239') ) {
<img src="https://cretecarrier.com/wp-content/uploads/2018/04/CreteCarrier_CreteLot-1500x430.jpg" width="1500" height="430" alt="" itemprop="thumbnailUrl" style="left: 0px;">



<div class="single_job_listing">
	
	<div class="flex_column av_one_half  flex_column_div av-zero-column-padding first  avia-builder-el-5  el_after_av_one_half  el_before_av_one_half  column-top-margin" style="border-radius:0px; ">
		<div class="avia-button-wrap avia-button-center  avia-builder-el-6  avia-builder-el-no-sibling "><a href="https://intelliapp2.driverapponline.com/c/cretecarrier" class="avia-button avia-button-fullwidth   avia-icon_select-no avia-color-theme-color " style="color:#ffffff; background-color:#C8102E; "><span class="avia_iconbox_title">APPLY NOW</span><span class="avia_button_background avia-button avia-button-fullwidth avia-color-black"></span></a>
		</div>
	</div>
		
	<div class="flex_column av_one_half  flex_column_div av-zero-column-padding   avia-builder-el-7  el_after_av_one_half  el_before_av_one_half  column-top-margin" style="border-radius:0px; ">
		<div class="avia-button-wrap avia-button-center  avia-builder-el-8  avia-builder-el-no-sibling "><a href="" class="avia-button avia-button-fullwidth   avia-icon_select-no avia-color-theme-color popmake-contact-a-recruiter " style="color:#ffffff; background-color:#C8102E; "><span class="avia_iconbox_title">CONTACT A RECRUITER</span><span class="avia_button_background avia-button avia-button-fullwidth avia-color-black"></span></a>
		</div>
	</div>

}  else {
    //nothing
}

?>
<div class="single_job_listing">
	
	
	
	
	<h2 class="big-6-title"><?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="_self"><?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

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
I am not seeing a white page.

A white page normally means an error. Try activating error reporting by adding the following to functions.php
define( 'WP_DEBUG', true );

Open in new window

Jon ImmsWeb Developer

Author

Commented:
I'm actually now seeing the header and footer, no content. And footer is empty.  Not sure what is happening.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
Put a messing in the else part of your if statement
Line 39 =>
echo "Page not found on line: " . __LINE__;

Open in new window

What do you see now?
Jon ImmsWeb Developer

Author

Commented:
Parse error: syntax error, unexpected '<' in /www/wp-content/themes/enfold/job_manager/content-single-job_listing.php on line 22

Open in new window

Jon ImmsWeb Developer

Author

Commented:
cannot figure it out
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
	if( is_page( array('19672', '25239') ) {
<img src="https://cretecarrier.com/wp-content/uploads/2018/04/CreteCarrier_CreteLot-1500x430.jpg" width="1500" height="430" alt="" itemprop="thumbnailUrl" style="left: 0px;">

Open in new window

Do you see it?

You have HTML output in your PHP block. Should be
	if( is_page( array('19672', '25239') ) {
?>
<img src="https://cretecarrier.com/wp-content/uploads/2018/04/CreteCarrier_CreteLot-1500x430.jpg" width="1500" height="430" alt="" itemprop="thumbnailUrl" style="left: 0px;">
...
<?php
}
else {
 // Nothing
}

Open in new window

Jon ImmsWeb Developer

Author

Commented:
Thanks Julian,

I see that now,  but when i go with that, i get the following error?

Parse error: syntax error, unexpected '?>' in /www/wp-content/themes/enfold/job_manager/content-single-job_listing.php on line 22

Open in new window


<?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
}

?>
<?php
	if( is_page( array('19672', '19673') ) { 
?>

<img src="https://cretecarrier.com/wp-content/uploads/2018/04/CreteCarrier_CreteLot-1500x430.jpg" width="1500" height="430" alt="" itemprop="thumbnailUrl" style="left: 0px;">


<div class="single_job_listing">
	
	<div class="flex_column av_one_half  flex_column_div av-zero-column-padding first  avia-builder-el-5  el_after_av_one_half  el_before_av_one_half  column-top-margin" style="border-radius:0px; ">
		<div class="avia-button-wrap avia-button-center  avia-builder-el-6  avia-builder-el-no-sibling "><a href="https://intelliapp2.driverapponline.com/c/cretecarrier" class="avia-button avia-button-fullwidth   avia-icon_select-no avia-color-theme-color " style="color:#ffffff; background-color:#C8102E; "><span class="avia_iconbox_title">APPLY NOW</span><span class="avia_button_background avia-button avia-button-fullwidth avia-color-black"></span></a>
		</div>
	</div>
		
	<div class="flex_column av_one_half  flex_column_div av-zero-column-padding   avia-builder-el-7  el_after_av_one_half  el_before_av_one_half  column-top-margin" style="border-radius:0px; ">
		<div class="avia-button-wrap avia-button-center  avia-builder-el-8  avia-builder-el-no-sibling "><a href="" class="avia-button avia-button-fullwidth   avia-icon_select-no avia-color-theme-color popmake-contact-a-recruiter " style="color:#ffffff; background-color:#C8102E; "><span class="avia_iconbox_title">CONTACT A RECRUITER</span><span class="avia_button_background avia-button avia-button-fullwidth avia-color-black"></span></a>
		</div>
	</div>
<?php
}  else {
    //nothing
    echo "Page not found on line: " . __LINE__;
}

?>
<div class="single_job_listing">
	
	
	
	
	<h2 class="big-6-title"><?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="_self"><?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

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Jon ImmsWeb Developer

Author

Commented:
You are awesome Julian!

Thank you!!!!
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
You are welcome.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions