If you have been reading posts on the Voxeo blog site, you’ll notice that any posts that I have written have included this footer at the bottom of the text:
If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook or following us on Twitter.
I want to include this as a direct note asking people to join us in the various conversational services (FB, Twitter) or to subscribe. Yes, we have the same links in our first sidebar, but I also want it in the post itself.
However that text does not show up on anyone else’s posts – only mine. The reason, of course, is because I have been manually adding that footer when I write the blog posts in MarsEdit. This obviously has several problems:
- As mentioned, it only shows up on my posts.
- I have to remember to manually add the footer.
- On the rare occasions when I post through the WPMU web interface (or a mobile interface), the footer doesn’t get added there.
- Because I have different footer macros in MarsEdit, they have over time gotten out-of-sync. For instance, they have used different URLs for getting to Voxeo’s Facebook page.
This has been very clearly something to automate through adding it to our theme… it’s just been an issue of not having enough of those darn “round tuits”. Today I finally made the change.
Now, the first intuitive place for me to look down in our “voxeo-default” theme was naturally footer.php. However, that puts any text way down at the bottom of a page. I wanted it to appear right up underneath the body text of an entry.
THE SOLUTION
It turns out that there were really three places I needed to add some text. Rather than adding the footer to three separate files, though, I first created a new file that I called “post-footer.php” and included this text:
<hr>
<p><em>If you found this post interesting or helpful, please consider either
<a href="<?php bloginfo('rss2_url'); ?>">subscribing via RSS</a>, becoming
<a href="http://www.voxeo.com/facebook/">a fan on Facebook</a>, or
<a href="http://twitter.com/voxeo/">following us on Twitter</a>.</em>
<hr>
Note that I’m using a WordPress variable to show the blog feed appropriate to the specific blog, but in the case of Facebook and Twitter they are both static URLs. (You’ll also note I’m using “http://voxeo.com/facebook” versus “http://www.facebook.com/voxeo“, which does also work, primarily because I’m interested in tracking click-throughs.)
Next, I started changing the relevant files. First, I changed the single.php file to have the following additional text (in red italic):
<div class="entry">
<?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
<?php include (TEMPLATEPATH . '/post-footer.php'); ?>
<p class="postmetadata alt">
Ta da… this footer now gets added to all posts to our blog site when they are individually viewed.
Second, I changed “index.php” to have this text:
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
<?php include (TEMPLATEPATH . '/post-footer.php'); ?>
<div>
This addressed the display of posts on the “main” blog page such as http://blogs.voxeo.com/voxeotalks/.
Finally I changed “archive.php” to look like this:
<div class="entry">
<?php the_content(); ?>
<?php include (TEMPLATEPATH . '/post-footer.php'); ?><div>
which gets archive pages of multiple posts such as http://blogs.voxeo.com/voxeotalks/2007/12/.
Note that because I modified single.php, anytime anyone clicks on any of the posts shown in the blog index or archive, they will see the post wrapped in the single.php template. If you didn’t want such a footer to appear for each post in the blog index or archive, you could simply not modify those files. I wanted to have the footer appear in all three views.
ALL IS GOOD, RIGHT?
The great aspect about this approach is that I can simply go into our theme and modify that single “post-footer.php” file if I want to update that footer text. For instance, at some point I may actually start using Voxeo’s identi.ca account and so I may want to add that link there.
Going back to my original four issues with manually adding the footer:
- The footer now shows up on all posts on the site.
- It is done automatically so I don’t have to remember to include it.
- Because it is on the display end of WPMU, it doesn’t matter how the blog post is created. It can come in through MarsEdit, through the WPMU web interface, through a mobile interface or really any other means.
- Footers across blogs never get out of sync because it’s the identical footer across all blogs.
ALMOST…
Now, here is one problem… the footer only shows up when the post is displayed on our site.
My main reason for starting to use the footer, really, was because I saw our content being scraped via the RSS feeds and appearing on other people’s sites. I therefore wanted to include the footer so that those sites blindly scraping our content would wind up including pointers back to our site and accounts.
Ideally, I like to really inject this footer at the time a blog post is created so that it is in the actual content of the post rather than the wrapping template that comes from the WordPress theme. Either that or have it injected in the RSS feed for each entry when that gets sent out.
However, for either of those I have to go outside the theme and get into either:
- Modifying the main WordPress MU files;
- Finding a plugin that will do this functionality; or
- Writing my own plugin to do this.
Perhaps at some point, I’ll do that… meanwhile, I’ll stick with modifying the display of the posts when they are viewed on our site.
P.S. Of course, there is the problem that all the posts that I have written now have TWO of these footers… but that’s just some time going through and removing that text from the content bodies…
Technorati Tags:
wordpress, wordpressmu, wpmu