WordPress.org

Ready to get started?Download WordPress

Forums

How to display only the title of a post (3 posts)

  1. integral
    Member
    Posted 9 years ago #

    Can someone help me on how to display only the title of the posts in the index.php?

    I wish to customize the blog in a way that only the title appears on the home page. Upon clicking the title the visitor is taken to a new page where one can read the entire summary of that post or navigate to other posts through that page.

    Please help

  2. Class
    Member
    Posted 9 years ago #

    Edit your (theme) index.php. <?php the_title(); ?> is your basic title without link.
    The codex: http://codex.wordpress.org/Template_Tags/the_title

  3. Michael Bishop

    Posted 9 years ago #

    For more comprehensive reading:
    http://codex.wordpress.org/The_Loop
    To answer your question, first thing I would do is copy your entire idex.php file in a text editor, and save it as home.php. That way, depending on your theme, you are only making changes to the home page, not all pages that require the index.php template
    (More indepth reading- http://codex.wordpress.org/Template_Hierarchy)
    Once in home.php look for this:
    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    That is where the loop starts.

    All you want then is this section
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

    Delete - or better yet, comment out by adding <!-- at the beginning of what you don't want, and --> at the end of what you don't want to use.
    Depending on the theme, there may be some conditionals afterward, but you want to stop the deleting or commenting when you get to this:
    <?php endwhile; ?>
    See if that gets you what you want, and if not, let us know.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags