Skip to content

Instantly share code, notes, and snippets.

@ajithrn
Created March 26, 2014 15:21
Show Gist options
  • Save ajithrn/9785848 to your computer and use it in GitHub Desktop.
Save ajithrn/9785848 to your computer and use it in GitHub Desktop.
Wordpress: custom taxonomy archive customization
<?php
//Define the function for customize archive page
function your_taxonomy_archive_customization ( $query ) {
if (($query->is_main_query()) && (is_tax('your_custon_taxonomy'))) {
$query->set( 'posts_per_page', '3' );
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
//Hook the function
add_action( 'pre_get_posts', 'your_taxonomy_archive_customization' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment