[Solved] Wordpress Top Category Function

Notes No Comments »

For the new geeks.co.uk design I needed a way of finding which top level category any given post was in and use that in the CSS to make various design elements of the page the specific colour of that top level category.

On geeks.co.uk, some posts are in a top level category, eg all News articles, and some are in sub categories, eg some Game Reviews are in Wii but not PSP etc.

Also, CSS won’t work with spaces in the names of labels so for categories like “Game Reviews” we have to remove the space to be useful as a CSS label.

Sometimes you want the function call to echo the category name to the page, eg when it’s used as a title of the page or in breadcrumbs. Sometimes you just want it returned to use in a CSS label, for example.

So here is my function:

function get_top_cat($css = false, $echo = false){
$maffcat = (array) get_the_category();
$maffpar = get_cat_name($maffcat[0]->category_parent);
if ($maffpar == ''){
$maffcat = (array) get_the_category();
$maffpar = $maffcat[0]->cat_name;
}

if ($css){$maffpar = str_replace (" ", "", $maffpar);}

if ($echo){ echo $maffpar;}
else{
return $maffpar;
}

}

Stick that in your theme’s functions.php and you should be able to call it by, for example,

get_top_cat('', 'true') - will put top category name with spaces on your page
get_top_cat('true', '') - will put top category name without spaces in your code

in your webpage files like single.php, archive.php etc

Nb. this works for two-level categories – it seems that this could easily be extended for more levels by further nesting.

[Solved] Wordpress Active Theme Broken

Notes No Comments »

Got a small scare when I went into Appearance -> Themes and I got this message:

“The active theme is broken. Reverting to the default theme.”

And my site was back into the default theme which obviously looked gash.

Panic over – the problem was that I had somehow deleted the root style.css for the theme.

[Solved] Delete Invisible Thunderbird Account

Notes No Comments »

As a ‘webmaster’ I use Thunderbird to download email from multiple email accounts all the time and was adding another to my list recently when I encountered an annoying wee problem.

In the Thunderbird account setup wizard I put in the wrong login name – I just guessed to be honest which isn’t usually a problem as you can try another easily enough – and thus it wasn’t able to login.

The problem was that when I went into ‘Account Preferences’ this account doesn’t appear, so I can’t edit it and change the login details.

Menu Path:

[In Windows & OSX]: Tools | Account Settings, or
[In *nix]: Edit | Account Settings
.. then, in the left pane, under the account name, Server Settings

However, every time I tried to download email it checked this account – and asked me for a password etc. This was annoying. How could I edit or delete this account if I couldn’t see it?.

Thanks to advice received on this thread I found the solution.

I was able to delete the offending (non) account by editing prefs.js in the main profile folder (for example, s4u1gg1e.default) .

[Solved] Sound Not Working After Ubuntu 9.10 Upgrade

Notes 2 Comments »

Discovered my sound was not longer working after the latest Karmic Koala upgrade (Ubuntu 9.10).

The solution:

Go to System –> Preferences –> Sound –> Output

Under this tab there were 2 sound cards listed both as “Internal Audio Analog Stereo” (the same one listed twice? why?)

Choosing the second rather than the first brought sound back.

Oaktree Accountancy Goes Live

Notes No Comments »

Fellow WCDA alumnus Chris Macleod has a new website for his accountancy business based in Cockermouth, Cumbria.

Website: Oaktree Acountancy

Another Wordpress re-theming.

[Solved] Apache restart error: server’s fully qualified domain name

Notes No Comments »

It seems that Red Hat Fedora must have changed a few settings over recent upgrades because I had a few things stop working when I did a simple Apache conf change to point a website at some parking space.

After editing /etc/httpd/conf/httpd.conf

I tried to restart with /sbin/services – where has this gone? In the end I had to resort to the ancient looking

/etc/rc.d/init.d/httpd restart

Then I got the exciting Apache restart error

Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Ehh?

Seems the solution is this:

echo HOST.DOMAIN.com > /etc/hostname

where HOST = Your host name, DOMAIN = Your Domain Name

Followed by:

/bin/hostname -F /etc/hostname

Restart now works.

[Solved] Wordpress Error: “open_basedir restriction in effect”

Notes 2 Comments »

Keep getting this error on Supanames hosted websites:

Warning: touch() [function.touch]: open_basedir restriction in effect. File(/tmp/all-in-one-seo-pack.zip) is not within the allowed path(s): (/home/mydomain/public_html/) in /home/mydoamin/public_html/wp-admin/includes/file.php on line 175

Download failed. Could not create Temporary file

Finally got the answer from Supanames support, which relates to this half of the answer:

http://support.supanames.co.uk/KB/a83/i-cant-upload-images-files-using-upload-file-script.aspx

What you also need to do is:
Enable PHP5 and also the session save path.

Hey presto the annoying error gone (give it a day or so).

Maff Wilson’s Webby Home

Notes No Comments »

Thought I’d update this old webspace and turn it into a more personal space for me to note events in the turning of the world and to give help to people that want to get in contact with me.

Fans of the old website never fear, it’s still here.

Just to let you know, I am a I am a freelance web developer and designer living in Cockermouth, Cumbria.

The website design projects I’ve worked on have been for some of the best web sites online. They have ranged from full-blown e-commerce solutions, highly successful webcam and forum sites to small, friendly homepages for small businesses and organisations.

I’ve been working in webpage design and website promotion since February 2000.

So if you think you may require my services please contact me.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in