I have been getting a steady stream of EMail requests to assist with programming problems. I enjoy helping others so please keep those questions coming. Unfortunately I cannot always assist. Just yesterday I was asked to assist with a Blogspot template problem. This is something I know nothing about. If anyone is considering starting a blog and knows something about Blogspot templates, here is a much needed niche for you to pursue.
If you are aware of a site that does offer the Blogspot advice referred to, please let me know. I would much rather refer someone to another site than just tell them that I cannot help them.
While I am on the topic of support, allow me to answer two little questions I have had more than once over the last few weeks.
How did you code the number of posts and comments shown in your sidebar?
This one is easy. You need to collect all the required information and then display it wherever you want to. I used the following code:
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts);
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
?>
<h4>Quick Stats</h4>
<p><?php echo('There are currently ' . $numposts . ' posts with ' . $numcomms . ' comments on this blog.'); ?></p>
This piece of code will show the number of posts that have been ‘published’ but it will unfortunately also include the ‘published’ pages. All posts awaiting approval will be excluded. The number of comments displayed will only be those that have been approved.
You do I get the copyright date in my footer to update automatically?
Yet another easy one. I use the following code:
<div id="footer">
<?php if (date("Y") == '2008') : ?>
<p>&amp;amp;copy; <? echo date("Y"); ?> <strong>Nice2All.com</strong> - All Rights Reserved | <a href="http://wordpress.org" title="Powered by WordPress" rel="nofollow">Powered by WordPress</a> | Theme by Nice2All</p>
<?php else : ?>
<p>&amp;amp;copy; 2008 - <? echo date("Y"); ?> <strong>Nice2All.com</strong> - All Rights Reserved | <a href="http://wordpress.org" title="Powered by WordPress" rel="nofollow">Powered by WordPress</a> | Theme by Nice2All</p>
<?php endif; ?>
</div><!-- close footer -->
This blog was only started in 2008. At present it shows the copyright notice as © 2008. The moment the year changes to 2009 this notice will automatically change to © 2008 - 2009.
I hope you can find a use for these little snippets.
Till next time.























Awesome tips, I’ve never thought of displaying this. I was curious and checked out the tables. I think it is possible to say AND where post_type=’post’. I have to test it though.
You could be right. As soon as I have a bit of time I will check it out. If this works it will remove the pages. Thanks for commenting.
I am against using code for something extremely rare. What’s the point of using code that executes on every single page load for something that can be simply edited once per year?
Automation is good, but automation that is wasting resources instead of conserving them is pointless.
I do suppose it is a matter of choice. I prefer to not change my markup at midnight every new year. This is ’server side’ code so you are talking very little resources.
I have to agree with Lyndi here, use of the PHP date function uses practically no resources at all. If it were polling several db tables then fair enough, but this PHP is so simple (and effective) that there is no measurable resource hit at all.
I have a site I get quite a few blogspot tips from, you may want to check it out, http://www.bloggerbuster.com
I hope it may help someone. I also do allot of searching on Google too.
Have a great Sunday!
Thanks Jodi, I have bookmarked your site. Next time I receive Blogspot queries I will refer them to your site. Thanks for leaving the link.
Lyndi,
Thanks for the tip on the copyright date update, that is a nice 2 all tip to have.
Thanks. Why you landed in the moderation queue I do not know. Have you changed your email address or something? Maybe this beta version of WP still has some bugs in it!
Nothing has changed on my end with email addresses, must be a bug.
Found it, on the last two comments you spelled ’squeaky’ with a lower-case ’s’. On the others you used uppercase. This is a bit too sensitive if you ask me but now I know what is causing this. Funny it did not effect the ‘no-follow’ setup. The one works on the user name the other on the EMail address (or maybe the URL).
I guess it’s not easy to help someone on the area where you are not an expert
Maybe you can convince those that use Google Blogger to move to Wordpress instead
The more the merrier. It would be boring if we were all on WordPress.
Some days ago I recieve an email with a Blogspot question.. All I could do was do a quick Google search and see if I could help him anyway..
That is of course, also always an option.
Awesome tips Lyndi! Thanks for this!
Thanks, I hope you can use at least some of it.
The rounded corners on your comments are sexy
And they by association, they make your threaded comments sexy too.
Thanks. It is a pity they are not rounded in all the browsers, yet.
This is true. I’m not seeing it rounded in IE but I can still see them in my mind - and they are still beautiful hehe
Useful tips from you. Thanks.
Thanks and welcome here. I will come check your site out.
Excellent tips Lyndi! I also have a Wordpress blog but don´t feel like messing up the code.So, I use different plugins instead.
Thanks and welcome here.
Nice tip.
Quick question about 1st tip. Will those two queries to find the number of posts and comments be executed everytime we view the page? If yes then is it not a performance issue?
Not really. see the comments by Rarst and Jim shown above.
Thanks for the information Lyndi. It’s always a pleasure to visit your site. Every time I (rather we) get to know something new!
Thanks Arun, like I told another commenter recently, flattery will get you everywhere.