1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need php help pls urgent

Discussion in 'PHP & Perl' started by michaeladewale2010, Aug 23, 2016.

  1. michaeladewale2010

    michaeladewale2010 Junior Member

    Joined:
    Jan 14, 2015
    Messages:
    162
    Likes Received:
    39
    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.
     
  2. MRX

    MRX Newbie

    Joined:
    May 21, 2016
    Messages:
    7
    Likes Received:
    5
    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"
     
    • Thanks Thanks x 1
  3. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,537
    Likes Received:
    5,854
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    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 Thanks x 1
  4. MRX

    MRX Newbie

    Joined:
    May 21, 2016
    Messages:
    7
    Likes Received:
    5
    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
     
    • Thanks Thanks x 1
  5. michaeladewale2010

    michaeladewale2010 Junior Member

    Joined:
    Jan 14, 2015
    Messages:
    162
    Likes Received:
    39
    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
     
  6. redarrow

    redarrow Elite Member

    Joined:
    Apr 1, 2013
    Messages:
    4,267
    Likes Received:
    975
    <?php
    if ( is_page('598') ) {

    Echo"stick the image here";

    Code.

    ?>
     
  7. michaeladewale2010

    michaeladewale2010 Junior Member

    Joined:
    Jan 14, 2015
    Messages:
    162
    Likes Received:
    39
    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?
     
  8. michaeladewale2010

    michaeladewale2010 Junior Member

    Joined:
    Jan 14, 2015
    Messages:
    162
    Likes Received:
    39
    still uppin this. pls does anyone have a solution for?
     
  9. michaeladewale2010

    michaeladewale2010 Junior Member

    Joined:
    Jan 14, 2015
    Messages:
    162
    Likes Received:
    39
    • Thanks Thanks x 1