WordPress.org

Ready to get started?Download WordPress

Forums

different text at top of page on different page (2 posts)

  1. graham85
    Member
    Posted 1 year ago #

    down vote favorite

    I have at the very top of my page a line of text within a h1 tag thet i use for seo reasons. the text and html around it is written in my header.php. but i would like to write differnet txt so it appears different on each page for seo reasons. for example:

    • homepage- line of text reads builders in lancaster, builders in morecambe etc
    • plastereing page- line of text reads plasterers in lancaster, plasterers in morecambe etc
    • roofing page - line of text reads roofing in lancaster, roofing in morecambe etc

    i know theirs a widget logic but thats for widgets and not the main header.php. is their a line o of code i can write in the header.php to do what the widget logic would do.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    Code similar to this should do what you want:

    <?php if ( is_page('Entries') ) {
       $text = 'This is the Entries page';
    } elseif ( is_page( 'Blog') ) {
       $text = 'This is the Blog page';
    } else {
       $text = '';
    }
    if ($text) {
       echo "<div class='page_message'>$text</div>";
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.