Edit category.php file in order to create a glossary

2 posts in this topic



In order to create a glossary, I would like to display posts alphabetically within a specific category template.

As described here, I need to insert this piece of code:


<div id="content">
// we add this, to show all posts in our
// Glossary sorted alphabetically
$args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
$glossaryposts = get_posts( $args );
// here comes The Loop!
foreach( $glossaryposts as $post ) :    setup_postdata($post);  ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>

My problem is I can't find the category-XX.php file I need to modify into wp-content > themes > pagelines folder.

I know I must not modify PageLines core files so I currently use a child theme (wp-content > themes > pagelines-template-theme) but I can't neither find any category.php file into it.


Any help please?

Share this post

Link to post
Share on other sites

Further down the page you would have found the answer...

function foo_modify_query_order( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
add_action( 'pre_get_posts', 'foo_modify_query_order' );
1 person likes this

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now