WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] the_title() (3 posts)

  1. ABoooo
    Member
    Posted 2 years ago #

    Hi guys,
    I'm a newbie and don't know much of a programing either, but I want to learn how to create custom templates for WordPress.

    I am calling content on my page with a loop like this

    <?php
    if (have_posts()) :
    while (have_posts()) : the_post();
    echo '<h2>';
    the_title();
    echo '</h2>';
    the_content();
    endwhile;
    endif;
    ?>

    but this means that I see title on all the pages not only on posts. So I would like to remove title for static pages with certain IDs and leave title only on a page with blog posts. How can I achieve this?

    Thanks
    AB

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    remove title for static pages with certain IDs

    if( !is_page(array(3,67,345)) ) the_title();

    meaning: if it is not one of the static pages with those IDs, then show the title.

    http://codex.wordpress.org/Function_Reference/is_page

    whole list of other conditional tags:
    http://codex.wordpress.org/Conditional_Tags

  3. ABoooo
    Member
    Posted 2 years ago #

    Cool, thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags