How to not use get_cat_name for a taxonomy in WordPress – use get_term_by instead!

If you’ve got a custom post say ‘regions’ and you’ve defined a few categories in this, initially like me you might think that get_cat_name would get the text value of the category if you had the ID integer.

Well, I spent about half an hour just now trying to figure out why this wouldn’t work.

The answer is :

Use get_term_by() instead!

To help you out :

$brand_search = get_term_by(‘id’ ,$_REQUEST['brand'], ‘brands’ );

You only really need the first three arguments. The first signifies that you are searching by id, the second is the value you want to match as an id, and the third is the name of the taxonomy.

This function returns an object and as such to get the name you would use:

$brand_search->name

Done :D

How to lookup category name by ID in WordPress

Basically we want to find the category name, and we have the ID. Maybe this has been passed by a select dropdown. Real simple :

echo get_cat_name( $_REQUEST['region'] );

where the $_REQUEST would be the dropdown result

I tend to use :

<? if ($_REQUEST['region'] == ’0′) { echo ‘All Regions’; } else { get_cat_name( $_REQUEST['region'] ); } ?>

So that if nothing has been selected, the system takes it as ‘all’ regions.

Hope that helps!

How To Show User Choice : wp_dropdown_categories and html select box

A typical WordPress function to show a drop down might be :

<?php wp_dropdown_categories(‘name=brand&id=brand&show_option_all=Select Brand&taxonomy=brands’); ?>

To get the drop down to show the value that was previously selected, obviously the value will be held in <? echo $_REQUEST['brand']; ?> and since the wp_dropdown_categories has an argument called selected we can just do :

<?php wp_dropdown_categories(‘name=brand&id=brand&show_option_all=Select Brand&taxonomy=brands&selected=’.$_REQUEST['brand']); ?>

That should work :)

 

Damn Sinusitis!

Well today I am still suffering from sinusitis, a by product of my earlier man flu! I’m being looked after well by Kate, and have football later at the UEA; and I’m slowly battling through the work loads that I have on at the moment. Every day I’m learning more about developing for WordPress and enjoying it immensely. There’s still a few improvements that WordPress needs to make it a really effective business tool for clients and the major one is making it more user friendly to actually get content onto the websites; a simple repeated region like a left aligned image with text on the right hand side, causes all the rows to overlap each other. Something to develop a solution for!

Loving WordPress a lot and thoughts on business

I’ve been working a huge amount with WordPress sites over the past few months. Whilst I wish I could use Smarty templates in the themes to make them nice and clean, I’m making do with what I’ve got. Once you really delve into developing WordPress and understanding all the functions you really do start to see the real power of it. There’s a lot of talk about ExpressionEngine and Ruby CMSs being the best for large scale sites, but I haven’t used these myself – WordPress I think is great for both designer, developer, customer and visitor. I think the thing that held me back was thinking that you need a strict tabular design with WordPress but really you can take any website and convert it to an editable form for your clients, really good. Rant over!

2012 marks a year where I want to make a major change in how I do business, since the past few years have been relatively unsuccessful on a professional perspective. I’d say on a personal perspective things have been excellent, almost a 8 / 10. But this year anyway, I have debts to pay off, and changes to make. I talked about having a vision in an earlier post this year and any business changes that I make should be aligned really with one or more of these aspects of my vision. However, I’m not going to make any changes until I’ve got on top of my current situation – for the past few years I have tried setting goals and take on big projects but I am reminded of the following Bill Gates quote :

The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency.

Basically, I take from this the following – if you are already inefficient at doing what you are doing, and you try and heap a load of other stuff on top of what is already an inefficient operation, then everything is going to fail spectacularly. So, the head of my list for 2012 is to become larger than my current place… Huh?

You can advance only by being larger than your present place, and no one is larger than his present place who leaves undone any of the work pertaining to that place.

The world is advanced only by those who more than fill their present places.

A little quote I’ve taken to heart from the Science of Getting Rich there. Basically it makes a lot of sense. If you have things unfinished in your life, and you are trying to start lots of new things, then you aren’t going to get anywhere. The unfinished things are going to drag you back, and keep you in place.

 

Man Flu Recovery and Getting Back to Work

Well yesterday the man flu took a turn for the worse and completely flat lined me for the entire day. I couldn’t think straight or concentrate so I resigned myself to a day lying on the sofa trying to get better. Happily, that was the last of the man flu and now today I feel a whole lot better. I’m a little annoyed that a clean start to 2012 was obstructed by this, since today is the first day I actually feel well this year, but at least it’s over.

Whenever I need to get back into work, I take time to sit still and calm my mind through meditation. I remind myself to lock into gratitude and abundance (I now see these as absolutely tangible and no longer some ‘airy fairy’ concepts that no-one has ever heard of) and then I make a plan of attack. I normally will set a timer for ten minutes and focus on one project at a time for the next few hours. This allows me to cover everything I am doing in a matter of hours. This includes accounts, paperwork, taxes, emails, client projects, invoices, long term projects, my own websites, marketing and sales. I will normally do six things at first, then take a short break, then carry on. I make an attempt to cover everything that I consider an active project.

It’s surprising what you can accomplish in ten minutes if that is all you have to use, and whilst I’m an advocate of focusing for extended periods of time on one project, I like to use this ‘island hopping’ methodology every so often to keep up to date with everything that is going on.

New Years Man Flu & Work

The past three days I’ve been struck down by man flu. I don’t normally get ill for more than two days maximum but I’m now on my third day, and it’s been getting worse – headaches, earache, general ache, ridiculous nose blowing, fever, tiredness and basically feeling crap. However, business doesn’t stop when you’re ill, so I’ve resolved to do what I can today – doing something is better than nothing after all!

Happy New Year

Happy New Year

I greet you with a Happy New Year from Norwich, UK. 2011 certainly went very quickly – it feels like only yesterday that I was cleaning up the flat on the 1st January 2011 after a New Years Party. I’m really happy that it’s now 2012, and I’m looking to make this the best year that I’ve had yet both personally and professionally.

2011 – The Year of a Negative Entity?

Looking back at last year, it’s incredible the amount of time I wasted each day when I could have been taking care of business. It was as if I was possessed by some negative entity who just simply wouldn’t let me work however much I tried. I would force myself to get some work done, but immediately I would have a massive resistance to doing it. I was certainly in a negative cycle. When you do this when you are self-employed, everything suffers – money, life, family, friends, social stuff, health, etc. Maybe one day I will make the time to meditate over the reasons for it, but going forward I’ve learnt several key principles that you must have if you wish to have a successful life.

Key Principles for a Successful Life

Create a Vision Document

A vision document is a one page overview of your ideal lifestyle and it should be the result of a good amount of thinking, writing and condensing down all those ideas that you’ve had about what you want to achieve in your life. When you have a vision of what your ideal lifestyle is like, you have a pathway to follow. I think that everyone can find it ridiculously easy to make a vision document; we all know really what we value in life, and it’s just a matter of making the effort and put it down in writing. My vision is split down into twelve sections and when I read the whole document, I really feel like there is nothing to add or subtract from it. That’s how I know it’s the right vision for me. A vision doesn’t need to be earth shattering – paradigm shifting or world changing; for me one of my values is simply to play football far more often and to get qualified as a FA coach. Playing football each week is a really simple thing to achieve, but if you are self-employed and don’t make it a priority then likely you won’t fit it into your schedule. That’s what having a vision is all about – knowing what your priorities are.

START LOOKING AT LIFE DIFFERENTLY with an attitude of gratitude

I am amazed at how powerful the concept of perception is, when you truly understand it. What I mean, is that as we grow into adults we automatically carry along with us our old understandings of the world that we learnt as we grew up. Thus someone can look at the same situation completely differently from another person. In almost all esoteric and classic learning material that I have read, the concept of gratitude is named as the foundation to a happy life. In certain cases, gratitude is linked to the law of attraction (if you believe in that!) and I personally believe that learning about gratitude can be the key to unlocking a negative mind and creating a really positive, enthusiastic personality.

Let’s take a fairly simple and common situation. You are broke and have no money. Even worse, you owe money to friends, family and banks. This is a mindset of poverty and the more you focus on it the more likely you are to feel negative about your situation. The more you feel negative, the less personal power you have to actually change the situation because working hard becomes a lot more difficult when you’re feeling despondent about your life. However, I’d like to point out that virtually everyone I know, whether they have money or not, is immensely rich when you consider our standard of living. We have homes with central heating, plumbing, entertainment, cookers, fridges, showers, etc. One hundred years ago, a king would be proud of the bed I wake up in, the carpet I walk on, the hot water coming from the shower and the whole range of other riches we have just within our houses. The kings of yesterday would not be able to fathom the technology we have at our disposal – WE ARE LIVING IN PARADISE PEOPLE, AND WE DON’T EVEN KNOW IT! If I wanted to I could go further; sometimes I will walk into town and marvel at the absolute abundance around us – even the most obvious things like pedestrian pavements (sidewalks), traffic lights, tarmac roads, brightly lit shops with every convenience and let’s not even talk about the mind boggling variety of food we can choose from in the supermarkets…

And that is the point of gratitude. It’s a new way of perceiving life, and when you do it actively you really do wake up to the reality of our situation – whether you are tens of thousands of pounds in debt, the absolute reality is that you are immensely rich when you live in the Western world. For this you have to be thankful. Recognising abundance around you is a game you can play with yourself, and what’s more, you will never be the same. You will be happier, more positive and way more genuinely thankful for living at this time in history. This sort of positivity can go a long way toward making yourself a success.

This only scratches the surface – start thinking about your family, your friends, your customers, your experiences, your holidays, your successes – start looking at all the great things that have happened to you in your life. My personal experience was that I was looking at things really harshly, nothing was ever good enough, and I never had enough, but once I started reading about the power of gratitude my world started to change, and it can change yours as well. Even if you already have a positive attitude you can still maintain and strengthen it further by being even more grateful for the small things in life.

That’s my blog post for today. Take it from me, taking the time to create your vision document; and then from now on every day see how ridiculously decadent we are, and start living a new life with enthusiasm for all these riches of abundance around us.

Happy New Year!