List post titles on category pages

Community Forums Forums Design Tips and Tricks List post titles on category pages

This topic is: not resolved

This topic contains 3 replies, has 3 voices, and was last updated by  essaysnark 1 year, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1418

    Steffen
    Participant
    Post count: 5

    Hi

    I would like the category-archive-page to show a list of all posts in that specific category.
    How can I make this happen ?

    The list should only show the posts title, and should be sorted alphabetically.
    I think something like this: http://sangetilboern.dk/tekster-til-julesange/

    I have a lot of categories, so it’s not possible to make a new page for each category, but the archive page should automatically put the page up.

    Hope someone can help me out here.

     


    New Hits Publishing publish sheet music for drumcorps, marimbabands and more.
    See more at newhits.dk.

    #14147

    CathyT
    Participant
    Post count: 38

    You’ll need to upload a blank file to the child theme and name it archive.php

    add this code

    [code]
    <div class="line" id="file-gistfile1-aw-LC4">/** Props http://www.billerickson.net/customize-the-wordpress-query/**/</div&gt;
    <div class="line"><?php</div>
    <div class="line">add_action( 'pre_get_posts', 'child_archive_display' );</div>
    <div class="line" id="file-gistfile1-aw-LC13">
    <pre>
    <div class="line" id="file-gistfile1-aw-LC12">function child_archive_display( $query ) {</div>
    <div class="line" id="file-gistfile1-aw-LC15"> $query->set( 'order', 'asc' );</div>
    <div class="line">  $query->set( 'orderby', 'title' );</div>
    <div class="line" id="file-gistfile1-aw-LC18">}</div>
    <div class="line"></div>
    <div class="line">
    <pre>remove_action( 'genesis_post_content', 'genesis_do_post_content' );

    genesis();
    [/code]

    #35245

    essaysnark
    Participant
    Post count: 333

    Just in case anyone follows along behind, the code above seems to have gotten clobbered by the editor. Hopefully this works better:

    [php]
    <?php
    /**
    * Template Name: Archive
    * Props http://www.billerickson.net/customize-the-wordpress-query/
    **/
    add_action( ‘pre_get_posts’, ‘child_archive_display’ );
    function child_archive_display( $query ) {
    $query->set( ‘order’, ‘asc’ );
    $query->set( ‘orderby’, ‘title’ );
    }
    remove_action( ‘genesis_post_content’, ‘genesis_do_post_content’ );
    genesis();
    [/php]

    #35246

    essaysnark
    Participant
    Post count: 333

    Scratch that; moot point. The pre_get_posts() hook won’t work in an archives.php template page, which Bill points out on his tutorial.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.