need php help pls urgent

michaeladewale2010

Regular Member
Joined
Jan 14, 2015
Messages
278
Reaction score
102
i am trying to place a conditional statement in my theme's php code to display an image on a particular page instead of the normal header text that it displays on all the other pages. but i want this for only one page. so i found the right file to edit under Apearance > Editor but when i edit the php code i am getting the following screen:https://s10.postimg.io/hmeud12rt/error.png

seems there is a mistake somewhere in my code. as i see the code is not being read as code but as text. here is the exact php script i entered. i entered it where the string calling the initial header is supposed to be. i just replaced that script with this one:

if ( ! is_page('598') ) {
echo '<img class="marginn" src="http://www.bellefullcatering.com/wp-content/uploads/2016/08/Bellefull-Logo-NEW.png" alt="" width="300" height="179">'
}

else {
echo '<h1 class="headline__primary"><?php esc_html_e( $title ) ?></h1>'
}

pls can someone show me what is wrong with my code and why it wouldnt display properly. thanks very much.

using Rosa Restaurant theme and i cant send links to the page because it is being worked on locally. thanks very much.
 
Close each line with ";" bro

EDIT: except for brackets

EDIT2: remove <?php ?> because you are already in php code. So for example "abc".some_func()."123" instead of "abc<?php .... ?>123"
 
Code:
<?php
if ( is_page('598') ) {
echo '<img class="marginn" src="http://www.bellefullcatering.com/wp-content/uploads/2016/08/Bellefull-Logo-NEW.png" alt="" width="300" height="179">';
}

else {
echo '<h1 class="headline__primary"><?php esc_html_e( $title ) ?></h1>';
}
?>

Something like that perhaps?
 
Code:
<?php
if ( is_page('598') ) {
echo '<img class="marginn" src="http://www.bellefullcatering.com/wp-content/uploads/2016/08/Bellefull-Logo-NEW.png" alt="" width="300" height="179" />';
} else {
echo '<h1 class="headline__primary">'.esc_html_e( $title ).'</h1>';
}
?>

try this
 
Code:
<?php
if ( is_page('598') ) {
echo '<img class="marginn" src="http://www.bellefullcatering.com/wp-content/uploads/2016/08/Bellefull-Logo-NEW.png" alt="" width="300" height="179">';
}

else {
echo '<h1 class="headline__primary"><?php esc_html_e( $title ) ?></h1>';
}
?>

Something like that perhaps?

thanks...that took the funny looking header out and displayed the image on the page like i wanted it to

however the normal text header is no more showing on the other pages i.e. the text supposed to be triggered by the h1 tag above is not displaying.

what do i do? sorry my php sucks
 
<?php
if ( is_page('598') ) {

Echo"stick the image here";

Code.

?>
 
<?php
if ( is_page('598') ) {

Echo"stick the image here";

Code.

?>
what do you mean by 'Code' ? bro i appreciate ur help but i just mentioned that my php sucks..pls be more specific what you mean when u mention 'Code' what code specifically goes there?
 
Back
Top