Blog Archive links Collapsed by Default Hack

blog archive widget hack

If you are using the Hierarchy style for your Blog Archive widget then you must have faced the problem of auto expansion of drop-down list of a particular month which is currently in the calendar or to which the opened post belongs. This simple hack solves that problem by making all the nodes in the hierarchy to be collapsed by default(As seen in the above picture ). This can be simply added by the One Click Installer or manually.

Demo


Prerequisites for this to Work
Before you apply this remember that you have to have a Blog Archive Widget present and the Style has to be set to Hierarchy (as shown in picture below )

blog archive widget config blogger


Applying this to your Blog

To add using One Click Installer Method



Or just add the following Code in your Blog (preferably before the </body> tag in the Edit HTML of the Template tab )

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>  
if ( $('.archivedate').hasClass('expanded') ) 
{ 
 $('.archivedate').removeClass('expanded'); 
$('.archivedate').addClass('collapsed'); 
}
</script>


What this code does
It firstly checks if a element having class name "archivedate" also has a class "expanded" present in it. If this turns out to be true then it removes the "expanded" class and adds a class named "collapsed" .

If you face any problem implementing it in your blog then feel free to ask via comments

Written by Prayag Verma

Find me on Twitter

Email Newsletter

Like what you read here in this post ?
Get new posts delivered straight to your inbox

Post a Comment

Prayag..you are master of tutorial..really I like it.

Anonymous said...

Usefull tips. i'll aply to my blog.

Tank you very much my friend.

Thank you! This was way easier to install than the other code (http://sedatkurtulus.blogspot.com/2010/05/keep-archive-hierarchy-collapsed-on.html).

Mike said...

Hey Prayag! Works great, thanks! The only thing I noticed is that the little triangle button (that signifies collapsed or not) stays "expanded", is there any way to fix this? Not a big deal though!

M@k said...

Bro This is working very well but I would Like to informs you that it Reduced my Traffic. hence It is not good for blogger. This my experience.
Sorry Bro.

Asim Nawaz said...

Thanks for this hack!
Will this hack work on wordpress if I use archive there too ?

nicoyuey said...

Thanks for this code. Worked great on my mobile/desktop website.
http://calcunico.blogspot.com

Keep sharing. Great work

Unknown said...

THANK YOU! Your technique is the easiest and most useful one!

Unknown said...

Is there a code to delete the bullet points from it?

is there a way to edit the little arrowheads? I moved mine to a static page but the arrowheads are gone now

http://chefuy.blogspot.com/p/archive.html
Thanks!

Asep said...

I finally found the easiest way here and working very well on my blog.

http://super-gratisan.blogspot.com
Thank you very much

Tranquil said...

WOW! Thanks man! Worked like a charm!

Ganesh said...

How can I do the expand all (Year and month). in archive?

Gaurav said...

Hey thanks for this, but the code is little buggy.

The triangle of the code is already down whenever we open the archive though the content is collapsed. It does not look good.

Second how can we collapse only the months and not the year?

Would be grateful for the response.

Warm Regards

Unknown said...

Hi,

Works well, I'm having some trouble finding a way to do the opposite (Like Ganesh asked in 2014)

I would like to display the 6 most recent posts in the header of any page in a Blogger blog.

The archives widget, with a hierarchy style unfortunately doesn't work, any posts which were published in the same month are expanded and displayed, but other months are collapsed and not visible until the href="javascript:void(0)" is triggered by the user clicking on the dropdown ►.

Is there a way to do this?

Zelus said...

Thanks for your simple and useful tip... was frantically googling for tutorials but the others seemed complicated/didn't work.

Also, I took away this tag under 'BlogArchive1' because some of my posts didn't have titles, so now all the posts will be displayed.

Amr Hamdy said...
This comment has been removed by the author.