• Hi,
    On my webpage MMAmania.dk i want to place banner at the top like on this test page i have Test Page but on the “test page” it is placed in the header.php and is therefore, one each page. And this I would like to avoid, as there are some pages where it will not be optimal.

    I hope someone can help me with this

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter Daniel Nielsen

    (@dabeni)

    If you have problems accessing the site, I’ve taken a screenshot which you can find on this link here

    I also want this to know

    It depends on what page(s) you want the banner to display on. You can edit the header.php with an if statement. This if statement will insert the banner on the front page only:

    <?php if (is_front_page()) { ?>
    // code to insert banner
    <?php } ?>

    You could also use if (is_single( ” )) or if (is_page( ” )) or others to insert on only certain posts/pages (obviously inserting the proper post number or page number between the quotes).

    Thread Starter Daniel Nielsen

    (@dabeni)

    Thanks, that helps! But where do i find the page numbers?

    If you edit a post in the admin, look at the URL. For example:

    …/wp-admin/post.php?post=8&action=edit

    The above URL shows “post=8”, so your if statement would be

    <?php if (is_page( '8' )) { ?>
    // code to insert banner
    <?php } ?>
    Thread Starter Daniel Nielsen

    (@dabeni)

    Can I combine this with the front page? I apologize for the newbie questions, but can it be made such that it is on every post or should I go and fix the code for each time I make a new post?

    Do you only want the banner to show on the front page, or every page other than the front page, or some combination of pages and the front page?

    Thread Starter Daniel Nielsen

    (@dabeni)

    I want to show the banner on the front page and on each post, maybe later also on other pages.

    It sounds like you want it to show up on all pages except a few, am I correct?

    You could try something like this:

    <?php if ( !is_page( '8' ) || !is_page( '10' ) || !is_page( '12' ) ) { ?>
    // code to insert banner
    <?php } ?>

    Should put the header on all pages that are not page_id 8, 10 or 12.

    Thread Starter Daniel Nielsen

    (@dabeni)

    Thanks for you time, but now I have tried this, but it still shows in our team page. (it is page 28)

    <?php if ( !is_page( '9' ) || !is_page( '23' ) || !is_page( '28' ) || !is_page( '901' ) || !is_page( '700' ) || !is_page( '126' ) || !is_page( '2327' ) || !is_page( '148' ) || !is_page( '1544' ) ) { ?>
    // My code
    <?php } ?>

    Try !is_single( ’28’)

    Thread Starter Daniel Nielsen

    (@dabeni)

    it’s the same result

    Are these “pages” or posts? If they are posts, do they all have a custom post type?

    Any other information you can provide me would make it easier for me to troubleshoot…sorry I haven’t solved it yet!

    Thread Starter Daniel Nielsen

    (@dabeni)

    It’s pages, you can see the team page here

    I changed the code back to

    <?php if (is_front_page()) { ?>
    // code to insert banner
    <?php } ?>

    The pages that I did not want the banner displayed on is 9, 23, 28, 901, 700, 126, 2327, 148, 1544

    If there is other information you need? There is no reason to apologize, I’m just glad you bother to help me.

    Thread Starter Daniel Nielsen

    (@dabeni)

    I’ve tried both !is_page(‘ 28 ‘) and !is_single(‘ 28 ‘) and banner will be shown no matter what

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Placement of banners’ is closed to new replies.