WordPress.org

Ready to get started?Download WordPress

Forums

Exclude Title On Certain Page and Replace with Text (5 posts)

  1. quaziblue
    Member
    Posted 4 years ago #

    I am using the following code to list the page title in the sidebar.

    <h3>
    <?php wp_title("");?>
    </h3>

    I want to be able to do two (2) things:
    1. use this code on every page except page with post id= 1202
    2. On Page w/ id=1202, show "Test" instead.

    Below is my attempt at it, but it doesn't work. Any help would be appreciated.

    <h3>
    <?php
    if (is_page(1202) {echo "Test"}
    else {<?php wp_title("");?>}
    ?>
    </h3>
  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Try using:

    <h3>
    <?php
    if (is_page(1202) {echo "Test"}
    else {<?php the_title();?>}
    ?>
    </h3>
  3. quaziblue
    Member
    Posted 4 years ago #

    Thanks for the code, but it didn't work. It just removes then entire snippet like my code does. Any other suggestions?

  4. zeta1600
    Member
    Posted 4 years ago #

    Will this work?

    <?php
    if (is_page('1202')){echo 'Test';}
    else { ?>
    <?php echo the_title();?><? }
    ?>

    I just used this to remove a title on a specific page.

  5. brightfire
    Member
    Posted 4 years ago #

    I wonder if you all might be able to help me. I am trying to do something very similar to this.

    I have both pages and posts. I am putting the page title under my navigation (in a different area than the default placement of the title for pages).

    I have it just about working. There is not title on the home page which is correct. My two problems are:

    1) I would like the blog page to Say Blog for the title.
    2) I would like to have all the posts within the blog to have the page title Blog but not change the title of the actual blog post on the page.

    Here is the code I have so far:

    <?php if (is_home() || is_front_page() ) {
    /*Do nothing*/
    } elseif (is_category('1')|| is_front_page() ) {
    /*Do nothing*/
    } else {
    the_title();
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic