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 2 years, 2 months ago.

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

    Steffen
    Participant

    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

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

    add this code

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

    essaysnark
    Participant

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

    &lt;?php
    /**
     * Template Name:  Archive
    * Props <a href="http://www.billerickson.net/customize-the-wordpress-query/" rel="nofollow">http://www.billerickson.net/customize-the-wordpress-query/</a> 
    **/
    add_action( &#8216;pre_get_posts&#8217;, &#8216;child_archive_display&#8217; );
    function child_archive_display( $query ) {
        $query-&gt;set( &#8216;order&#8217;, &#8216;asc&#8217; );
                   $query-&gt;set( &#8216;orderby&#8217;, &#8216;title&#8217; );
    }
    remove_action( &#8216;genesis_post_content&#8217;, &#8216;genesis_do_post_content&#8217; );
    genesis();
    
    #35246

    essaysnark
    Participant

    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.