Forums

If conditional not doing as it's told (2 posts)

  1. offthepost
    Member
    Posted 5 months ago #

    Hi

    I'm not a code/Wordpress expert in the slightest, so apologies if this is in the wrong section, doesn't give you the necessary information etc.

    I'm using a Conditional Tag and the Exec PHP plugin to show an advert only in the sidebar of my homepage. It's the third sidebar item down headed Top Gambling News: http://www.offthepost.info

    For some reason the advert is displaying on a few other pages which it shouldn't be. Some examples:

    http://www.offthepost.info/page/532/?altcast_code=7685ed111a
    http://www.offthepost.info/page/128/?altcast_code=0e50dffb09
    http://www.offthepost.info/page/425/?p=nqytuptfltm
    http://www.offthepost.info/page/59/?p=nqytuptfltm
    http://www.offthepost.info/page/1387/?altcast_code=4967632bdd

    Any ideas why that would be / how to make sure it appears only on the homepage?

    Code below.

    Thanks,

    Rob

    [code moderated - please use the pastebin]

  2. kionae
    Member
    Posted 5 months ago #

    I think you want to use if(is_home()) function, or if(is_home && is_front_page()), depending on how your site is set up.

    If you set a static page for the main page of your site, is_front_page() will return true when viewing that page. Otherwise, it returns the same as is_home() would. is_home() checks if the main page is currently being displayed.

    So if your main page is a blog posts listing and not a page, is_front_page() will return false, even though is_home() returns true.

Reply

You must log in to post.

About this Topic