Forums

tag insertion using get_the_id() (3 posts)

  1. micasuh
    Member
    Posted 3 years ago #

    I'm trying to add code to one specific page out of all the other pages. Here's the code:

    <?php
    // Header tagline insertion
    if ( get_the_id() != 3 ) { echo ?>
    <h1 class="page-title">/" title="<?php the_title(); ?>"><?php the_title(); ?></h1>
    <?php } else { ?>
    <p class="page-title"><img src="<?php echo get_option('home'); ?>/wp-content/themes/brilliance/images/sttm-tagline.png" alt="Tagline" /></p>
    <?php } ?>

    For some reason, this code is not working the way I was hoping! Basically, if the page id is not 3, it should add an H1 to the pages. If the id IS 3, it should add the image. I can't make it work like I was hoping and I don't know what's wrong!

  2. micasuh
    Member
    Posted 3 years ago #

    I'm thinking it has something to do with the else but I really don't have enough php experience to know. Thanks for anything you can suggest.

  3. jonkemp
    Member
    Posted 3 years ago #

    You need to use a function like this.

    if(is_page($ID)) {
    	some code here;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic