Category Navigation Option

Posted in: Newspaper
Post count: 263

I know that this code randomizes the posts inside their category

function exclude_category( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
        $query->set( 'orderby', 'rand' );
    }
}
add_action( 'pre_get_posts', 'exclude_category' );

I am currently using this. Is there a way to set a top navigation area where it gives the option to click for the Newest since its now at Random? Maybe even a ‘Newest | Most Popular | Random’ option.

Thanks in advance!

Post count: 6600

Hi,

Unfortunately the theme doesn’t have a feature like that and you will need custom work to achieve that as we work hard on the development, updates, fixes and support we cannot offer custom work.
You can try to find a plugin that dose that or you can always get a freelancer from sites like: http://studio.envato.com/ if you don’t know how to do it yourself.

Thanks

Post count: 263

@Lucian, I used the random posts in categories code (which I believe is td_module_blog). I want to put the original code back instead of random; what is the original? orderby cat or new…?

  • This reply was modified 11 years by sbo.
Post count: 263

*Disregard my last post. The td_module_blog orderby is for the below the post and I see that ‘date’ is for the newest to appear first. What is the category page file to change that?

Post count: 6600

Hi,

You need to edit the functions.php file to add that function for category posts.
The category template is category.php file which use the loop.php file.
You can read here more about the default values: http://codex.wordpress.org/Template_Tags/wp_list_categories

Thanks

Post count: 263

Okay I got it. It was in functions.php I had to change ran to date.

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.