Yay, I’ve now managed to do something I always wanted for my site. It always bothered me that when I wrote a lengthy blogpost, the right side of the screen always stayed empty when you scrolled down. Unfortunately I did not want to just chuck a few random items to expand it as it would mean that even when I wrote a short post, the sidebar would draw the post down which would have the unfortunate results of making the reader scroll down too much to read the comments (as well as look ugly)
After I used the FSD Sidebar I thought to myself that I really should find a solution to my dilemma. Initially I though to use different post templates and then just select one depending on how lengthy the post came out. Unfortunately, after I created the first, I discovered that WP does not support different templates for posts but only for pages. Unfortunately I could not find a plugin to activate this functionality. This was a bit unfortunate but I didn’t give up.
I went for my second idea: To have the single-post sidebar expand downwards with more items depending on the word count of the current post. I looked around the documentation for a way to collect the word count of a post but nothing was built in WP. Fortunately a short Googling led me to the page of someone who created a plugin exactly for this reason. Perfect!
Now I only needed to figure out how to use a php statement so that the sidebar does this expansion. Unfortunately since I don’t have any php skills to speak of, I turned to the nets again and fortunately it was easy to find what I needed. Unfortunately this statement does not accept an actual sidebar item within the brackets {} but a quick look at other themes informed me to the use of <?php if() ?> and <?php endif(); ?> statement. I still don’t know exactly how to use it properly but I did manage to make it work for me so all’s well.
All in all what I did is test if the wordcount is over a specific limit and then insert the item between the if and endif. Use four of these statements for increasing wordcounts, and your sidebar will expand only when you write an appropriate number of words. Of course this doesn’t take into account pictures or videos, or even different screen resolution that might change the size , but I don’t know if there is a way to test this unless I start checking their resolution each time and changing the word count needed…hmmm…
Ack no!