WordPress.org

Ready to get started?Download WordPress

Forums

alphabetical listing of posts???? (9 posts)

  1. antonskey
    Member
    Posted 9 years ago #

    Is there any way to get an alphabetical listing of posts in any given category? I'd like to create a page or post that lists the 148 posts I have it in that category and have each link to their respective posts. Any help would be amazing.

  2. nmallory
    Member
    Posted 9 years ago #

    Add this line:

    <?php if (is_category()) { $posts = query_posts($query_string . '&orderby=title&order=asc'); } ?>

    above this line:

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

  3. antonskey
    Member
    Posted 9 years ago #

    awesome, and is there any way to then only get the title from each post as opposed to the entire post? i'm using the blue radiant theme and it doesn't have an archive.php file, so would i need to add one?

  4. moshu
    Member
    Posted 9 years ago #

    Either that or a category.php template; see Template hierarchy in the Codex: http://codex.wordpress.org/Template_Hierarchy
    Once you have created it (e.g. saving your index.php as archive.php or category.php) you can delete the call for the_content (and anything else you don't need) and have only the clickable titles.

  5. antonskey
    Member
    Posted 9 years ago #

    wow, i think i'm finally getting the hang of things a little. i think this will be my last question, and that's is there any way now to specify that i want ALL the posts in that category on that one page without changing the Options->Reading to 148?

  6. moshu
    Member
    Posted 9 years ago #

    Not really, but there are at least two plugins that make possible to have different number of posts in different views:
    http://wordpress.org/support/topic/31491#post-177815

  7. antonskey
    Member
    Posted 9 years ago #

    that's perfect, thank you very much.

  8. nmallory
    Member
    Posted 9 years ago #

    Actually, there is.

    Again, here's my code from my index.php (main page):

    <?php if (is_category()) { $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1'); } ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    The 'posts_per_page=-1' tells it to post them all.

    Here is the code further down that tells it whether to use just the title & date or output content too:

    <?php if (is_home() || is_date() || is_author()) { ?>
    <div class="meta"><?php _e("filed under"); ?> <?php the_category(',') ?> <?php _e("on");?> <?php the_time('l j F Y'); ?> <?php _e("at");?> <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    <?php } else { ?>
    <div class="meta"><?php _e("on");?> <?php the_time('l j F Y'); ?> <?php _e("at");?> <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    <?php } ?>

    <?php if (!is_category() || !is_archive()) { ?>
    <div class="storycontent">
    <?php if (is_home() || is_date() || is_author() || is_archive() || is_category()) {
    if ( in_category('5') ) { the_excerpt_reloaded(30, <i><em><img><a><b>
    <ul>
    <li>
    <ol><br>, content, TRUE, (more...), TRUE, 2, TRUE);
    } else {
    the_excerpt_reloaded(50, <i><em><img><a><b>
    <ul>
    <li>
    <ol><br>, content, TRUE, (more...), TRUE, 2, TRUE);
    }
    } else { the_content(); }?>
    </div>

    (Note: I am using the_excerpt_reloaded () plug-in rather than the default the_excerpt() function.)

    Here's how my category pages look as opposed to my index page.

  9. msmeltem
    Member
    Posted 8 years ago #

    nmallory I like the way yr category page looks, but somehow I'm not able to get this code to work. I'm a newb which might be the cause, but I need help, pls.. When I add the code in my index file it returns a blank page.. Where am I doing wrong? Thanks for yr input..

Topic Closed

This topic has been closed to new replies.

About this Topic