Forums

[resolved] else_if not recognizing static home page and blog (5 posts)

  1. davidallred
    Member
    Posted 1 year ago #

    I'm looking for some advice. I am wanting a different image to show up on each page in the header. I am using the else_if commands and can get the different images showing up for all of my pages except the home page and blog page.

    I have the settings pointing to a static home page and have the blog at /blog.

    Here's the code and the url is http://www.dityseo.com:

    <div id="<?php
    if(is_page('home')){
    echo "pagetitleseo";}
    elseif(is_home()){
    echo "pagetitleseo";}
    elseif(is_page('website-optimization')){
    echo "pagetitlewebsiteoptimization";}
    elseif(is_page('start-a-blog')){
    echo "pagetitlestartablog";}
    elseif(is_page('search-engine-optimization')){
    echo "pagetitleseo";}
    elseif(is_page('pricing')){
    echo "pagetitlepricing";}
    elseif(is_page('contact-us')){
    echo "pagetitlecontact";}
    elseif(is_page('blog')){
    echo "pagetitleblog";}
    ?>"></div>

  2. vtxyzzy
    Member
    Posted 1 year ago #

    Try using is_front_page() instead of is_home() for the static front page. I don't know about the blog.

  3. davidallred
    Member
    Posted 1 year ago #

    @vtxyzzy - That worked perfectly for the front page. Thanks. Still trying to figure out the posts page or the blog page. Obviously it's not connected to the name of the page in this case. If I figure it out, I'll come back and post the solution.

  4. davidallred
    Member
    Posted 1 year ago #

    is_home('blog') worked! Not sure if I needed the 'blog' in there but all is good. Thanks!

  5. vtxyzzy
    Member
    Posted 1 year ago #

    You are welcome. Now, please use the dropdown at top right to mark this topic 'Resolved'.

Topic Closed

This topic has been closed to new replies.

About this Topic