Thesis Video Tutorial: Customize Thesis with WordPress Custom Fields

Today’s quick Thesis Video tutorial will demonstrate how you can easily access WordPress Custom fields via Thesis Hooks. If you have been exposed to the power of Custom Fields, this tutorial will be great for you. If you haven’t used them you may want to read up on them at the WordPress Codex. Custom fields are how Michael Gray built his Thesis Carousel and how many other “Premium” WordPress display special information, such as “featured images.”

Within this tutorial we will guide you through how to use Thesis to display your own “featured images.” In a few weeks we will use this code to build a full featured slider for your theme. Once you have a mastery of WordPress Custom Fields you can essentially make Thesis do anything under the sun.

Bonus: While recording the video I realized some people may want to only show the hook they are modifying to themselves. So I’ve included this code as well. Remember to add your IP Address or you won’t see the hook either. :) If you want to know your IP Address look in the sidebar.

Please Note This is an Old tutorial. The examples used have changed.


YouTube Preview Image

Within this Video we used the following Thesis Hook:

have_posts()) : $my_custom_query->the_post();
					$key = 'training_text'; // Our Custom Field Name
					$img_array =	get_post_custom_values($key); //Holding array
					$featuredimage = $img_array[0]; //Assign Value

		?>
		
		

As explained in the video this hook, accesses the “thesis_post_image” custom field for our most recent post and assigns it to a variable. We then output the variable to the screen.

I am sure you will find this quick tutorial of use, especially if you want to take your Thesis Customizations to the next level.

If you have any questions or comments please leave them below.

Sign Up Now for Free Updates and Exclusive Content:

Learn how to write killer content, get more traffic, make money, and more by entering your email below:

Written by Nick Reese

Nick Reese is a multi-passionate entrepreneur who believes anyone can transform their business and life they they've got guts and hustle. He's also the co-founder of Broadband Now which aims to simplify the broadband shopping process.

Leave a Reply

Comments

  • Daniel Balfour says:

    Man… that’s really complicated. I totally lost you with the $my_custom_query = new WP_Query(‘showposts=1′); I mean what are you doing there? How are you getting $key or the post-ID?

    I think Thesis is a nice WP theme but it’s way to closed off and proprietary to be considered a framework.

  • Daniel Balfour says:

    Nick,

    Thanks for taking the time to write this out. I think I’m missing some basic information because I’m just not getting it. I looked up WP_Query() but again, it’s just over my head (I do know some basic PHP just not WordPress structure). Do you know of any basic (from the ground up) tutorial that goes through this with a simple, step-by-step example? Or perhaps you’d care to make one?

    I think you’re gonna make some great tuts man! you’ve ‘got it’. Stick with it.

  • Nick Tzu says:

    Daniel,

    I would suggest reading these two tutorials. the first goes over the basics of the loop. (the core code that makes WordPress display posts). The second one goes into detail on how to create custom loops, which is what we use in this tutorial.

    http://www.themelab.com/2008/04/04/the-ultimate-guide-to-the-wordpress-loop/
    http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/

    Hope this will make things a little more clear, if it isn’t i’ll try and make a tutorial explaining the loop.

  • Mic says:

    Hi there is was wondering if you could tell me how I could get the current post with this:
    $my_custom_query = new WP_Query(‘showposts=1′); //Custom Query – Find the First Post

    and not the first post.

  • I know this tutorial is out of date now but was wondering if there is a similar way of using something like this to create either a new meta box, or a custom field for an ad space, but have an if statement to validate that if the custom field is left empty then use a fall back default ad? Just a thought, love your blog and your work.

    :)

    • Nick Reese says:

      Here is some example code:

      function thesis_photo_credit() {
      global $post;
      $credit_name = get_post_custom_values(“photo_credit_name”);
      $credit_url = get_post_custom_values(“photo_credit_url”);
      if(isset($credit_name[0]) && isset($credit_url[0])){ ?>
      Photo Credit: <a href="” title=”Photo Credit for ” rel=”nofollow”>
      <? }
      }

  • Nick Tzu says:

    Daniel,
    I’ll do my best to explain what is going on here. Like I mentioned I’m no php guru, but I get it a bit.

    Essentially where we define a custom query starting with the line “my_custom_query” we ask wordpress to give us the most recent post. This takes the place of the post id.

    The while statement will walk through this post (and more if you queried more) and do whatever is between the begin “while” and the “endwhile.”

    In this example we are looking to get the custom wordpress field “thesis_post_image” which is where thesis stores the information on the post image you upload. $key is the name of the custom field you are using.

    What we do then is use the wordpress query “get_post_custom_values” for the key. This will return as an array. Of this array we want the first entry and we asign it to $featuredimage. We then echo out the featured image.

    Hope this makes it a bit clearer, that video was recorded VERY quickly with no rehersal or plan, I wanted to get it out and was pushed for time.

    Let me know if you have more questions.