Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 1

Rearrange in alphabetical order


Mwaziba

Question

11 answers to this question

Recommended Posts

  • 0

Are you saying you want the Category names alphabetized: Category "A", Category "B", ....Category "G",

or are you saying you want the books within the categories alphabetized: Category "G" - Books "A", "B",..."Z", Category "C" - Books "A", "B",..."Z"

or are you saying alphabetize them both?

Link to comment
  • 0

This code worked for me to alphabetize blog posts based on title name:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
  <script type="text/javascript">
      $(document).ready(function(){
          if( $('.blog-item').length != 0 ){
              var categories = []; 
              $('.blog-item').each(function () {
                categories.push({
                  categoryName: $(this).find('.blog-title').html(),
                  listItem: $(this)
                });
              });
              categories.sort(function(a,b) {
                var c = a.categoryName.toUpperCase();
                var d = b.categoryName.toUpperCase();
                return (c > d) ? 1 : ((d > c) ? -1 : 0);
              });
              $.each(categories, function(index, object){
                  object.listItem.appendTo(object.listItem.parent());
              });
          }
      });
  </script>

The only issue is that the pagination links at the bottom won't be alphabetized as well, so I had to hide them. If anyone has solved this problem I'd love to see that solution

Link to comment
  • 0
On 1/14/2021 at 11:40 PM, Teucer90 said:

This code worked for me to alphabetize blog posts based on title name:


<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
  <script type="text/javascript">
      $(document).ready(function(){
          if( $('.blog-item').length != 0 ){
              var categories = []; 
              $('.blog-item').each(function () {
                categories.push({
                  categoryName: $(this).find('.blog-title').html(),
                  listItem: $(this)
                });
              });
              categories.sort(function(a,b) {
                var c = a.categoryName.toUpperCase();
                var d = b.categoryName.toUpperCase();
                return (c > d) ? 1 : ((d > c) ? -1 : 0);
              });
              $.each(categories, function(index, object){
                  object.listItem.appendTo(object.listItem.parent());
              });
          }
      });
  </script>

The only issue is that the pagination links at the bottom won't be alphabetized as well, so I had to hide them. If anyone has solved this problem I'd love to see that solution

If you share link to blog post, we can give code to hide it easier.

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 1/11/2021 at 5:22 PM, Ekaland said:

r are you saying you want the books within the categories alphabetized: Category "G" - Books "A", "B",..."Z", Category "C" - Books "A", "B",..."Z"

This is what I would like please. Is this possible? 

Link to comment

Create an account or sign in to comment

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

×
×
  • Create New...