Genesis Explained Functions

freeflow mind mapIn previous parts of the Genesis Explained series I talked about actions and filters, but Genesis is so much more than that. One of the great things about Genesis is all the helper functions. Today I am going to very quickly review them then I dig into detail for each individual function.

First, lets look at the files. Just like everything else, the folders and file names will help us quickly find what we are after, so check out the genesis/lib/functions/ folder.

  • admin.php: ( two functions that create checkbox output )
  • depreciated.php (functions that shouldn’t be used any longer since they have been replaced by new functions)
  • feed.php (an action and filter with their functions to redirect the feed)
  • formatting.php (functions to format text or returned values of other functions)
  • general.php ( for functions that don’t fit in well with others. Often these will build until a logical group can be formed and a new file is added)
  • hooks.php (assigned hooks to a function, look here for a list of hooks)
  • i18n.php (theme translation file)
  • image.php (functions for retrieving the thumbnails)
  • layout.php (functions to change the layout/layout options of the site
  • menu.php (the genesis_nav() function)
  • options.php (functions for retrieving options and custom fields)
  • seo.php (functions related to theme SEO)
  • upgrade.php (handles the theme upgrade)
  • widgetize.php (handles creation of default sidebars, footer sidebars, and provides the genesis_register_sidebar() helper function)

OK, so now you have some idea of what is in the files. Take time to read through them. We will be discussing most of the files and functions within in the upcoming articles of the series, but I want to get you started with some of the most often used functions. Again, the full details will come later, but for now check this out

genesis_get_image()

This function and genesis_image() work to retrieve the featured image. Actually it does so much more. It will also pull the first attached image if you forget to set a featured image. There are several arguments that can be passed, which will will discuss in detail later. The difference in genesis_get_image() and genesis_image() is that genesis_image() will echo the value returned by genesis_get_image(). This means you don’t have to type out “echo” when working with the function. There are plenty of neat tricks you can do as a result of how this works.

genesis_get_custom_field()

Like genesis_get_image() there is a genesis_custom_field() function that echos the genesis_get_custom_field() value. This uses the $post->ID automatically and only requires the field key.

get_the_content_limit()

Another handy function that can be used as the_content_limit() to directly echo the value. This function uses get_the_content() to retrieve the content and then limit it. This is similar to the_excerpt() but with several advanced featured like easily adjusting the length, more accuracy (character count v word count), and built in read more link.

I know this is just whetting your appetite, but don’t worry, soon and very soon I’ll be digging into these key functions, all the arguments they take, and any filters you can access to adjust the output.

In the mean time, be sure to subscribe to the feed or signup for the feed to be delivered to your email by putting your email in the sidebar widget. Don’t forget to put together your ideas for the Child Theme Creation Wish List.

Comments

  1. Oh – that genesis_custom_field is new to me – and VERY handy!! I’ve been using the wp functions. Is there a downside to using the WP functions instead of genesis? Actually why does Genesis duplicate something that is already there in WP?

    • nickthegeek says:

      I’ll go into this in more detail, but since Genesis uses functions for pretty much everything, you have to always remember to declare $post global before you can use $post->ID. Using this save a bit of code since it is global in the function, and it’s a bit shorter than the WordPress function, which also makes for more condensed code. There are a couple of limitations, for example you can’t work with multiple values since it isn’t setup for an array, but for 99% of the uses out there it is a much more efficient bit of code. Again, I’ll be digging into it in more detail in a future post.

  2. Nick,

    Thanks for the tutorials. I appreciate them. Looking forward to the new ones!

  3. Thanks Nick as always for the series. I am grabbing more and more of Genesis due to this :)

  4. thanks for this series. While the forums and tutorials are great over at Studiopress, these tutorials are really helpful to me.