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

Rearrange in alphabetical order


Mwaziba

Question

Hi there,

I have a blog on books and I would like to organise them in alpahbetical order. All the book titles are entered as blog titles. Can anyone help me?  

Link to post
  • Answers 11
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

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

This thread should be helpful, be sure to read the whole thing:  

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> <scr

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 post
  • 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 post
  • 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.

Link to post
  • 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 post

Create an account or sign in to comment

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


×
×
  • Create New...