NiceThemesDisplaying articles alphabetically (rather then by date posted) – NiceThemes http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/feed/ Mon, 21 Apr 2025 14:11:35 +0000 http://bbpress.org/?v=2.5.12-6148 en-US http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6362 <![CDATA[Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6362 Fri, 25 Sep 2015 22:43:34 +0000 lisajoy Hey, we’d like to display our articles alphabetically as we’re using a coding system to ensure our articles are in a chronological order but I’m having a bit of trouble getting this to work.

I’ve tried adding this code to functions.php with no luck. Suggestions?

// function and action to order articles alphabetically

function alpha_order_classes( $query ) {
if ( $query->is_post_type_archive(‘articles’) && $query->is_main_query() ) {
$query->set( ‘orderby’, ‘title’ );
$query->set( ‘order’, ‘ASC’ );
}
}

add_action( ‘pre_get_posts’, ‘alpha_order_articles’ );

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6363 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6363 Fri, 25 Sep 2015 23:06:25 +0000 lisajoy I’ve tried a couple plugins like WP Post Sorting but this only seems to effect posts, not articles.

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6366 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6366 Sat, 26 Sep 2015 14:34:59 +0000 Juanfra Aldasoro Hello Lisa,

Thank you for writing. Our knowledge base function have some filters in order to change the default arguments for that function.

We’ve created a snippet in order to show how to modify the order of articles, you can have a look at it here: https://gist.github.com/juanfraa/d434bcc629647bc98393

You can include that snippet in your functions.php file, and change the orderby value for ‘title’. You can check the full list of orderby parameters here: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

Best,
Juan.

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6371 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6371 Sat, 26 Sep 2015 21:18:55 +0000 lisajoy Thanks for sharing the snippet but for some reason it isn’t affecting the article order. If tried inserting it into flatbase/functions.php and flatbase/includes/functions.php with no luck either time. I’ve updated values to reflect title:

ie:
function nice_knowledgebase_article_order( $args ) {
$args[‘orderby’] = ‘title’;
$args[‘order’] = ‘ASC’;
return $args;
}
add_filter( ‘nicethemes_knowledgebase_default_args’, ‘nice_knowledgebase_article_order’ );

Any tips?

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6374 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6374 Sun, 27 Sep 2015 14:41:28 +0000 Juanfra Aldasoro Hello,

Thank you for the follow up.

The functions file you need to edit is the following: /flatbase/functions.php

Please be sure that you copy the exact same code that I’ve shared with you, using the same single quotation marks. When you are in the gist page, click the “Raw” button and copy the code from there. Do not include the php opening tag.

Best,
Juan.

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6379 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6379 Sun, 27 Sep 2015 19:41:04 +0000 lisajoy Hi Juan,

I’ve followed these instructions exactly with no affect on article reordering.

See my page of articles (still displaying by date): http://wiki.kudoz.ca/article-category/culture-values

I provided credentials initially when opening this ticket and have copied functions.php code below to demonstrate.

*****************

<?php
/**
* Flatbase by NiceThemes.
*
* Init NiceFramework – PLEASE DO NOT EDIT THE LINES BENEATH.
*
* @package Flatbase
* @author NiceThemes
* @license GPL-2.0+
* @link http://nicethemeswp.com/theme/flatbase
* @copyright 2014-2015 NiceThemes
* @since 1.0.0
*/
// If this file is called directly, abort.
if ( ! defined( ‘WPINC’ ) ) {
die;
}
// filter the knowledgebase parser

function nice_knowledgebase_article_order( $args ){
$args[‘orderby’] = ‘title’;
$args[‘order’] = ‘ASC’;

return $args;
}

add_filter( ‘nicethemes_knowledgebase_default_args’, ‘nice_knowledgebase_article_order’ );

/**
* Init NiceFramework – PLEASE DO NOT EDIT THE LINES BENEATH.
*/
require_once ( get_template_directory() . ‘/engine/bootstrap.php’ );

/**
* You can add your code below =)
*/

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6391 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6391 Mon, 28 Sep 2015 14:51:18 +0000 Juanfra Aldasoro Hello Lisa,

Would you please add the function below these lines:


/**
* You can add your code below =)
*/

Best,
Juan

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6394 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6394 Mon, 28 Sep 2015 15:58:15 +0000 lisajoy Hi Juan,

The articles in the knowledge base block (in homepage template) are now displaying alphabetically but what I was requesting initially was for the category pages (archive.php template I believe) to display them alphabetically.

Working > http://wiki.kudoz.ca/ (see knowledge block)
Not working > http://wiki.kudoz.ca/article-category/comms

]]>
http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6399 <![CDATA[Reply To: Displaying articles alphabetically (rather then by date posted)]]> http://nicethemeswp.com/forums/topic/displaying-articles-alphabetically-rather-then-by-date-posted/#post-6399 Mon, 28 Sep 2015 21:11:04 +0000 Juanfra Aldasoro Hi Lisa,

Well, that’s a template that uses the auto generated query by WordPress, we haven’t modified the query there.

For that case, you were in the right direction by using the filter for pre_get_posts. You should check that you are asking if the post type is “articles”, when it is “article”, and using that function as a method of the $query object, when it is an independent function.

At the same time you were viewing the article category archive and not the article archive. Because of that you weren’t seeing any results. What you need to do is ask if the current page is the default taxonomy page for “article-category” (and ‘article-tag’ to make it work in every archive page).

I’ve created a snippet for you to check: https://gist.github.com/juanfraa/cf1979da9bff55518f14

Best,
Juan.

]]>