Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>At the top of category.php template in your theme's root directory, add the following to add your custom sort field to the query:</p> <pre><code>&lt;?php function is_valid_custom_sort_field($field) { // implementation left as an exercise for the questioner return true; } if ($_REQUEST['sort_custom_field'] &amp;&amp; is_valid_custom_sort_field($_REQUEST['sort_custom_field'])) { query_posts($query_string . '&amp;orderby='.$_REQUEST['sort_custom_field']); } </code></pre> <p>See: <a href="http://codex.wordpress.org/Function_Reference/query_posts" rel="nofollow">http://codex.wordpress.org/Function_Reference/query_posts</a></p> <p>If your theme doesn't have a category.php, here is a simple default template to base it on (copied from the included twentyten theme):</p> <pre><code>&lt;?php /** * The template for displaying Category Archive pages. */ get_header(); ?&gt; &lt;div id="container"&gt; &lt;div id="content" role="main"&gt; &lt;h1 class="page-title"&gt;&lt;?php printf( __( 'Category Archives: %s', 'twentyten' ), '&lt;span&gt;' . single_cat_title( '', false ) . '&lt;/span&gt;' ); ?&gt;&lt;/h1&gt; &lt;?php $category_description = category_description(); if ( ! empty( $category_description ) ) echo '&lt;div class="archive-meta"&gt;' . $category_description . '&lt;/div&gt;'; /* Run the loop for the category page to output the posts. * If you want to overload this in a child theme then include a file * called loop-category.php and that will be used instead. */ get_template_part( 'loop', 'category' ); ?&gt; &lt;/div&gt;&lt;!-- #content --&gt; &lt;/div&gt;&lt;!-- #container --&gt; &lt;?php get_sidebar(); ?&gt; &lt;?php get_footer(); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload