Community Forums › Forums › Design Tips and Tricks › List post titles on category pages
Tagged: archive, categories, template
This topic contains 3 replies, has 3 voices, and was last updated by essaysnark 1 month, 1 week ago.
-
AuthorPosts
-
November 23, 2012 at 4:36 pm #1418
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.January 23, 2013 at 3:31 pm #14147You’ll need to upload a blank file to the child theme and name it archive.php
add this code
<div class="line" id="file-gistfile1-aw-LC4">/** Props <a href="http://www.billerickson.net/customize-the-wordpress-query/**/" rel="nofollow">http://www.billerickson.net/customize-the-wordpress-query/**/</a></div> <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();April 13, 2013 at 1:34 pm #35245Just in case anyone follows along behind, the code above seems to have gotten clobbered by the editor. Hopefully this works better:
<?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();April 13, 2013 at 1:44 pm #35246Scratch that; moot point. The pre_get_posts() hook won’t work in an archives.php template page, which Bill points out on his tutorial.
-
AuthorPosts
You must be logged in to reply to this topic.