Guest Posted January 5, 2021 Share Posted January 5, 2021 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 comment
Guest Posted January 5, 2021 Share Posted January 5, 2021 I meant I have a website on with different blog posts as book titles. Link to comment
tazmeah Posted January 6, 2021 Share Posted January 6, 2021 Can you post a link so we can better understand your problem? Link to comment
Guest Posted January 6, 2021 Share Posted January 6, 2021 https://www.mwaziba.com Under "The Hub" the only way I can categorise is by tags which I have grouped into "themes". However, I would like all the books in alphabetical order which is labelled as page title on the website. Link to comment
Guest Posted January 6, 2021 Share Posted January 6, 2021 17 hours ago, tazmeah said: Can you post a link so we can better understand your problem? Thank you for your reply. Link to comment
tazmeah Posted January 6, 2021 Share Posted January 6, 2021 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? tuanphan 1 Link to comment
derricksrandomviews Posted January 12, 2021 Share Posted January 12, 2021 This thread should be helpful, be sure to read the whole thing: Link to comment
Teucer90 Posted January 14, 2021 Share Posted January 14, 2021 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 dnmddy 1 Link to comment
tuanphan Posted January 17, 2021 Share Posted January 17, 2021 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. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Guest Posted January 20, 2021 Share Posted January 20, 2021 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
MidnightClub Posted January 21, 2021 Share Posted January 21, 2021 Hi @Mwaziba, I know the plugin lazy summary allows to automatically order alphabetically blog post within a summary block. Then you would have to create on your page a summary block per category, that you order manually, and all the post within would be rightly ordered. Seems the simpler to me. Cheers, Fabien Link to comment
Guest Posted January 21, 2021 Share Posted January 21, 2021 Overwhelmed with everyones responses. I will give the ones I find easier a go. Thank you so much 🙂 Link to comment
hannah3 Posted May 31, 2022 Share Posted May 31, 2022 On 1/14/2021 at 11:40 AM, 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 @Teucer90 does this impact ALL blog items on a website? Like if I have 3 different types of blog pages on the website will they all be impacted by this? Link to comment
creedon Posted May 31, 2022 Share Posted May 31, 2022 48 minutes ago, hannah3 said: does this impact ALL blog items on a website? It depends on where the code is installed. If it is installed to Blog Settings > Advanced > Page Header Code Injection for the blog page, please see per-page code injection, then it will only effect that blog. If it installed to Settings > Advanced > Code Injection > FOOTER, then it would be a site-wide effect. A couple of notes. I don't know this code. Also simple code done client side is not sorting all your posts. It is only sorting the posts on the page. Unless you use a plug-in like Lazy Summaries as mentioned earlier, which works with summary blocks. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
johnbuedel Posted June 2, 2022 Share Posted June 2, 2022 Hey, all! I was looking for this solution as well, but for the Archive block. I've edited the original code. Now the Archive block will display your posts in alphabetical order as well. Here's the code: <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ if( $('.archive-item').length != 0 ){ var categories = []; $('.archive-item').each(function () { categories.push({ categoryName: $(this).find('.archive-item-link').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> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment