Created
May 11, 2013 05:06
-
-
Save zeroeth/5558969 to your computer and use it in GitHub Desktop.
Attach post labels to blog post as classes, see it in use at http://moctopsgolbblogspotcom.blogspot.com/ view source and search for "dogs_post"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- this goes in the <head> --> | |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| $(document).ready(function () { | |
| // For every post | |
| $('.post-outer').each(function() { | |
| // Find all its labels | |
| var label_links = $(this).find('.post-labels a'); | |
| // Extract the text from them and append _post | |
| var label_names = label_links.map(function() { return $(this).text()+"_post"; }).get(); | |
| // Add these to the post as css classes | |
| $(this).addClass(label_names.join(" ")); | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment