WordPress.org

Ready to get started?Download WordPress

Forums

Alphabetizing posts and displaying only post titles (10 posts)

  1. lstoll
    Member
    Posted 2 years ago #

    Is there code I can add to display my archived posts alphabetically? I have all of my posts sorted into parent categories, and then sub-categories (i.e. Recipes -> Breakfast). I already have a loop-category.php file that was created to display a bit of static test at the top of category pages. Also, is there any way I can get my archived posts to only display the post title? Right now my archive posts display the entire post.

    Thanks!!!

    * the blog I'm trying to edit is http://www.wildbasilliving.com

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Is there code I can add to display my archived posts alphabetically?

    You would need to add a custom query to the relevant template file (archive.php?). See http://codex.wordpress.org/Function_Reference/query_posts for details of how to modify the standard Loop query.

    is there any way I can get my archived posts to only display the post title?

    Simply modify your archive.php file to omit the_content().

  3. lstoll
    Member
    Posted 2 years ago #

    Hi Esmi, Thanks for your fast response. I got the alphabetical part, but I'm not sure where to delete "the_content()" part in the archive.php file. I don't see anything in the file that says the_content, only the following two phrases are found in the file:
    <div id="content" role="main"> and </div><!-- #content -->

    Sorry I'm so inept at modifying code!

    See below archive.php file:

    <?php
    get_header(); ?>
    
    		<div id="container">
    			<div id="content" role="main">
    <?php
    	if ( have_posts() )
    		the_post();
    ?>
    			<h1 class="page-title">
    <?php if ( is_day() ) : ?>
    				<?php printf( __( 'Daily Archives: <span>%s</span>', 'twentyten' ), get_the_date() ); ?>
    <?php elseif ( is_month() ) : ?>
    				<?php printf( __( 'Monthly Archives: <span>%s</span>', 'twentyten' ), get_the_date( 'F Y' ) ); ?>
    <?php elseif ( is_year() ) : ?>
    				<?php printf( __( 'Yearly Archives: <span>%s</span>', 'twentyten' ), get_the_date( 'Y' ) ); ?>
    <?php else : ?>
    				<?php _e( 'Blog Archives', 'twentyten' ); ?>
    <?php endif; ?>
    			</h1>
    <?php
    	rewind_posts();
    	 get_template_part( 'loop', 'archive' );
    ?>
    			</div><!-- #content -->
    		</div><!-- #container -->

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin]

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    You will need to create a custom loop-archive.php template file in your child theme.

  5. lstoll
    Member
    Posted 2 years ago #

    What code do I put in my loop-archive.php in my child theme?

  6. esmi
    Forum Moderator
    Posted 2 years ago #

  7. lstoll
    Member
    Posted 2 years ago #

    I created the loop-archive.php file with the paste bin code, and uploaded it to my child theme, but the entire post content is still showing up.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    Are you sure you uploaded the file to the correct folder? Only there's no code to output the post content in the pastebin version.

  9. lstoll
    Member
    Posted 2 years ago #

    I'm in my wordpress admin account right now under editor and the loop-archive.php is with all of my other child template files. You said there's no code to output the post content in the pastebin version. What do you mean by that exactly?

  10. esmi
    Forum Moderator
    Posted 2 years ago #

    There's no <?php the_content();> in the example code in the pastebin.

Topic Closed

This topic has been closed to new replies.

About this Topic