Amadiere.com

Fourteen and a half crazy frog burpers

24th January 2010

Blog posts redirecting to homepage

Filed under: Hosting,Wordpress — Tags: , — Alex Holt @ 3:30 pm

Over the last week or two, I hadn’t spotted but my blog posts were all redirecting to my homepage. This is due to my stupidity. Plain and simple. I didn’t check once the website had completed its move across hosting providers and the URL redirecting had failed.

However, it was fairly simple. When I visited the Permalink settings within WordPress, it came up with the following warning:

If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.

To fix it, it was just as easy – do exactly as it says. I updated my .htaccess file to include the following text.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /blog/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /blog/index.php [L]
</IfModule>

This probably wouldn’t have been such an issue, but the change of hosting provider (from GoDaddy to NearlyFreeSpeech.net) was basically going from a Windows box to a Unix box.

5th November 2009

Quick Start Guide to Theming WordPress

Filed under: Web Design,Wordpress — Tags: , , — Alex Holt @ 8:01 pm

It’s taken a while, but I finally revamped the look of my site. Part of the problem, as always, is coming up with a design I can put up with for a while. I think that this red attempt should be OK for a while.

There a number of good WordPress theming guides out there (the one at WPDesigner.com is especially excellent) , so I don’t intend to replace them and their great detail. This post is merely some simple pointers for those that already know how to create HTML and understand enough about PHP to get by.

Create yourself a design! I’m totally gonna gloss over this part, despite being the major time consuming bit. I’m a big advocate of the multiple stage design process (Image -> HTML -> System Template). Basically – once you have a HTML / CSS version of what you want to achieve, its then time to work on how to get that into your WordPress Blog.

Create yourself a theme directory – this is within your /wp-content/themes directory and should make your theme sound totally awesome. Something like “Totally Rockin’ Monkey Burgers” should be sufficient.

Create your CSS file – Just copy your CSS file to your theme directory and make sure its named stylesheet.css You should also make sure you have something like the following in the top of it:

1
2
3
4
5
6
7
8
9
/*
Theme Name: Totally Rockin' Monkey Burgers
Theme URI: http://www.amadiere.com/blog/2009/11/quick-start-guide-to-theming-wordpress/
Description: Theme creation example.
Author: Alex Holt
Author URI: http://www.amadiere.com
Version: 1.0
Tags: red,white,fluid-fixed-width,two-columns
*/

Copy the PHP files from the Default theme – these act as a great starting point for your adaptations. You can now adapt these to pull together to create your style. They are split into 5 easy to comprehend areas by default. You don’t need to follow this however, you can simply put everything in one big file – though I find code becomes a lot more manageable when split over a few pages:

Index – the glue of the page, it calls the other templates where required. The key lines are:

<?php
get_header();
get_sidebar();
comments_template();
get_footer();
?>

Header – has the top part of your blog that is repeated throughout your site.

Footer – similar to the header, the code that appears at the foot of every page.

Sidebar – your navigation bar. For this, you effectively only need a small bit of code. The ‘dynamic_sidebar’ function calls all the Widgets that are enabled. This then basically generates a load of <li>’s, one for each Widget (these sometimes have nested UL’s and LI’s themselves):

1
2
3
4
5
6
7
<div id="navigation">
  <ul>
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) {}
    ?>
  </ul>
</div>

It is however worth mentioning that in circumstances that there are no Widgets – the above would output nothing but an empty unordered list.

Comments – Just displays the comments (if set to show), below each post. While there are a lot of bits in here, the main bit can be a touch hidden and is signified by a foreach loop within an Ordered List “commentlist”.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
<ol id="commentlist">
  <?php foreach ($comments as $comment) : ?>
    <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
      <?php echo get_avatar( $comment, 80 ); ?>
      <div class="commentmeta">
        <?php comment_type(_x('Comment', 'noun'), __('Trackback'), __('Pingback')); ?>
        <?php _e('by'); ?> <?php comment_author_link() ?><?php comment_date() ?>
        @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a>
        <?php edit_comment_link(__("Edit This"), ' |'); ?>
      </div>
      <?php comment_text() ?>
    </li>
  <?php endforeach; ?>
</ol>

Create yourself a screenshot – it’ll make you feel good and will help you recognise the awesomeness that is your style when you are browsing through the hundreds you downloaded that are all tosh when compared with yours!

And that’s your lot.

As I mentioned, I don’t want to replace what is already out there on the web with this guide. In fact, I don’t the word ‘guide’ as it gets me quite excited and I expect something more dramatic than I’ve delivered. I think maybe prefixed with ‘Quick Start’ however, it might become acceptable… Yes. Yes, that seems not to have got my blood pumping!

9th May 2009

Changing WordPress Permalinks

Filed under: Wordpress — Tags: , — Alex Holt @ 3:29 pm

I didn’t think enough at the start, that’s the bottom line here.

I set up my blog and just had a little wander through the settings, not really examining them like I normally would do when I get a new toy. This is how I missed the settings for permalinks or at least I saw it, but paid it too little attention. When I eventually did decide I didn’t like this layout of URLs (/archives/%post_id%), it was too late.

I basically came to the decision to change them when looking at Google Analytics and the following was part of my report.

Wow, post 41, ooh yeah. A sweet, sweet day.... remind me what it was again?

Wow, post 41, ooh yeah. A sweet, sweet day.... remind me what it was again?

I was reviewing the most popular pages and I realised I had no idea what post 41 was. Absolutely no idea! So it was then it hit me – that archive permalink naming schema-thingy, it’s a bit, ya know, poop. But behold! I could change that! I’d alter the URLs so instead of this useless URL with a number in it, I’d change it and make it fantastic and include the URL-friendly post title as part of the Permalink.

There was much rejoicing!

So, I changed them – and the obvious happened. All my old links broke and became 404′s – losing all inbound Google traffic.

I decided I could live with that. I’m a grown man! What’s a 404 here and there, pffft! Google would update itself, right? It wouldn’t take long, surely…. But alas, it was a lie to myself as it was pecking at my head every time I thought about it. So eventually (today – after something like 3-4 weeks), I decided to do something about it. I thought that I would have to dig around with .htaccess files and MOD_REWRITE rules, something I am not masochistic enough to indulge in just yet. But, alas, a search around the Internet solved my problem!

I stumbled upon Dean Lee’s Permalink Migration Plug-in for WordPress. Genius! You can simply search for it in the plugins area of your blogs admin and install it simply from that route. It’s done what I needed exactly and it behaves how I wanted exactly!

After installing, I simply told it what my old links were clicked save and…. and…. oh. No change. My permalinks were already setup, so why wasn’t this working. I decided what I’d do is re-save my permalinks settings page and delete cache to see if that made a difference – I maybe should have checked after each one – but either way – one of them fixed it for me and now all my old links work again! :)

Old: http://blog.amadiere.com/archives/56
New: http://amadiere.com/blog/56/calculating-the-date-of-easter-programatically

Yes, that music you hear is the angelic chorus declaring the fantasticness of my links! :)

The best thing about this plug-in (other than not needing to delve into MOD_REWRITE), is that it redirects to the new URL instead of pretending the old one was fine. Well done, Dean Lee – take a bow!

So the bottom line is. Choose your permalinks wisely – they should be helpful enough that you can work out the content of the page from reading it, while at the same time being very nice to Google (and the other search engines…). I’m lucky because my blog isn’t popular – no one really noticed. But there were people hitting these 404′s who maybe could have done with some of the info in the posts.

Older Posts »

Theme designed & built for Amadiere.com by Alex Holt. Powered by WordPress