Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Quick Question on WordPress/PHP conditional tags.

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #31045
    Preeminent
    Participant

    Hey all,
    I have a problem and I’m sure it’s a very simple fix. I have one page of my wordpress site that needs to have a different logo image than the rest of the site. It’s working fine, except it’s also bringing in the default logo as well. I’ve been playing around with if/else statements and conditional tags, but cannot wrap my head around how to get this to work. I really don’t know any php, I’ve used just what I’ve seen from tutorials. Here is what I currently have:

    As you can see, when you are on the “STORE” template page, I need that “preemplateslogo.png” logo to display, which it is doing perfectly, but I now need to customize the rest of this code (that came with the theme I’m using). What’s happening though, is the default, regular “bloglogo.png” logo is also showing up right next to the “preemplateslogo.png” logo. How do I edit this, so that only the top statement is utilized on the “STORE” template page. I hope this makes sense to you all! Thanks!

    #69499
    clokey2k
    Participant

    I think adding an ‘else’ and wrapping the rest of the code should work. I think. Try:



    #69424
    clokey2k
    Participant

    oops, revert back for the time being, hopefully someone else will give it a go. :-)

    #68873
    Bob
    Member








    The above code worked for me, although I simplified it a bit using my own images and removing the bloginfo(‘url’) and such so you should put that back. It should still work then however.

    #68022
    Bob
    Member

    The $var==1 and $var==2 was just an example for me to be able to test it locally, ’cause if I used is_page_template(‘store.php’), it wouldn’t work for me since I obviously don’t have that page template here on my computer.

    Can you post your code like you have it now? Or did you not modify it at all? The code I posted above worked fine for me like I said, but you have to adapt it to fit your needs like I said. Thus, replace if ( $var==1 ) with if (is_page_template('store.php')) and so on.
    Basically, from what I see, the if..elseif..else statements I created should work; you just have to adapt it to your own code, so please post back what you have now.

    #67873
    Bob
    Member

    Ok, check out the following code:









    I’ve adapted it so it should fit your needs exactly. I put back in your links to your images etc.
    Try this code to see if it works, and if it doesn’t, post back why it isn’t working.

    #67734
    Bob
    Member

    Can you please post the whole error it is giving?

    #67671
    clokey2k
    Participant

    I think you have broken the ‘if’ statement when running:

    $customField1 = get_option("theme_logo");

    Maybe set that before the main ‘if’?

    #67494
    Bob
    Member

    Hmm, that is odd. Try removing the line:

    $customField1 = get_option("theme_logo");

    And replacing the line:

    elseif ( isset($customField1[0]) )

    with the line:

    elseif( is_page_template('templatnamehere.php') )

    Replace templatenamehere with another template you have, just make sure its different from store.php ’cause thats already being used in the first if statement so you wouldn’t see any difference then. Its just for testing purposes so either create a test template and use that in the above elseif statement or use an other template you have.
    See if that helps.

    #67312
    Bob
    Member

    Glad to hear its working.

    But hang on, if you leave it like that, you do realize the Logo, which belongs to the elseif ( is_page_template('TESTtemplate.php' ) ), will never show up right? If you’re ok with that, I’m glad because that means its working for you, but if you don’t mind it showing up at all, why did you add an if statement for it in the first place (see your first post)? Don’t you need the image to show sometime?

    #67257
    Bob
    Member

    Well if you don’t need the elseif statement at all, all thats left is a simple if…else statement, which would look like this:



Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘Back End’ is closed to new topics and replies.