EMail support

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;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;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.

Let's be sociable, come on, you know you want to. I appreciate the support.

Subscribe to feed Favorite on Technorati Submit to StumbleUpon submit to reddit

This entry was posted on Sunday, November 9th, 2008 at 1:50 pm and is filed under Markup, Tips, WordPress using as tag(s). You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

28 Responses to “EMail support”

  1. Øyvind says:

    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. :)

  2. 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.

    • Lyndi says:

      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.

      • Jim Sefton says:

        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.

  3. Jodi says:

    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!

    • Lyndi says:

      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.

  4. squeaky says:

    Lyndi,

    Thanks for the tip on the copyright date update, that is a nice 2 all tip to have.

    • Lyndi says:

      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!

      • squeaky says:

        Nothing has changed on my end with email addresses, must be a bug.

        • Lyndi says:

          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).

  5. 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 :)

  6. BioTecK says:

    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..

  7. fragileheart says:

    Awesome tips Lyndi! Thanks for this!

  8. Icon says:

    Useful tips from you. Thanks.

  9. Tom L says:

    Excellent tips Lyndi! I also have a Wordpress blog but don´t feel like messing up the code.So, I use different plugins instead.

  10. Nihar says:

    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?

  11. Arun says:

    Thanks for the information Lyndi. It’s always a pleasure to visit your site. Every time I (rather we) get to know something new!

Leave a Reply