Archived

This topic is now archived and is closed to further replies.

  • 0

Edit category.php file in order to create a glossary

Question

Posted · Report post

Hi,

 

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:

<?php
get_header();
?>

<div id="content">
<ul>
<?php
// 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; ?>
</ul> 

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

1 answer to this question

Posted · Report post

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