Forums

Changing the results of category listings (8 posts)

  1. eaglenick
    Member
    Posted 3 years ago #

    I would like to set up my blog in a way that I am pretty sure is possible; I just don't know how exactly to do it.

    I want it so when a user clicks a category name and is taken to the list of posts within that category, only the post titles appear instead of the entire posts.
    The titles should be links so the visitor can easily just click the title and be taken to the full article.

    Currently, it's like this:

    Categories >> News

    Article 1 Title
    --- This is the contents of the post entitled Article 1

    Article 2 Title
    --- This is the contents of the post entitled Article 1

    Article 3 Title
    --- This is the contents of the post entitled Article 3

    This is how I want it to look:

    Categories >> News

    Article 1 Title

    Article 2 Title

    Article 3 Title

    Where each title is a link to the full article.

    Any and all assistance is appreciated. You can see my blog here: http://www.lineolatedparakeet.net/blog

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    With the help of the Template Hierarchy article, determine what Template is displaying your category archives, then in that Template delete the use of the template tag, the_content().

    Also take a look at the first four questions in this section:
    http://codex.wordpress.org/FAQ_Layout_and_Design#Text_and_Content_Display

  3. eaglenick
    Member
    Posted 3 years ago #

    Hi Michael,

    Thanks for the links.

    I'm still having trouble; those pages make it seem too complicated.

    I made it to this page: http://codex.wordpress.org/Category_Templates

    The first step in modifying what happens when someone visits a Category page is to figure out which of your theme's files is going to be used to display the posts. This is known as the Template Hierarchy.

    In the case of categories, the hierarchy is fairly simple. For instance, suppose the ID number of the Category in question is 6. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme's directory from the following list:

    1. category-6.php
    2. category.php
    3. archive.php
    4. index.php

    Since I don't have the first three template files listed, so I'm now looking in the index.php file. The problem is that I don't see anything related to categories in that file... so I'm at a loss as to what to do.

    Here is my index.php file:

    `<?php get_header(); ?>
    <div id="main-wrapper">
    <div id="left">
    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <h2 id="post-<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h2>

    <div class="meta-data">
    <span class="auth-date">Author: <?php the_author();?> | Posted: <?php the_time('d-m-Y'); ?></span>
    <span class="comments-no"><?php comments_popup_link('0', '1', '%'); ?></span>
    </div>

    <div class="entry">
    <?php the_content('Continue reading »'); ?>
    </div>

    <?php endwhile; ?>

    <div id="post-links">
    <span class="prev-entries"><?php next_posts_link('Previous Entries') ?></span>
    <span class="next-entries"><?php previous_posts_link('Next Entries') ?></span>
    </div>

    <?php else : ?>

    <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif; ?>

    </div>
    <?php get_sidebar();?>
    </div>
    <?php get_footer(); ?>`

    Any further assistance is appreciated.

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    At a minimum you will delete
    <?php the_content('Continue reading ยป'); ?>

  5. eaglenick
    Member
    Posted 3 years ago #

    Thanks Michael, that worked.

    However, it also shows only the title on the homepage. I want it to be this way only when a user is viewing a list of all posts within a category.

    Regards,
    Nick

  6. MichaelH
    Volunteer
    Posted 3 years ago #

    You can copy that index.php to category.php in your theme sub-folder and then but that deleted statement back into your index.php

    or but this back where the_content statement was, in your index.php file:

    <?php if (is_category()) {
    the_content('Continue reading &raquo;');
    }
    ?>
  7. eaglenick
    Member
    Posted 3 years ago #

    Worked perfect, Michael! Thanks!!

    One last request:

    How can I get the category name to appear above the list of posts within that category?

    I sketched it here: http://lineolatedparakeet.net/blog/wp-content/themes/freshcitrus/images/screen.png

  8. MichaelH
    Volunteer
    Posted 3 years ago #

    Take a look at the WordPress Default Theme as the 'archive.php', which displays the category archives for that theme, has an example of file has an example of single_cat_title. It uses this:

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.