Generic custom functions

REFS:
 * To display post thumbnail if it is set, or first image upload to post: https://gist.github.com/germanny/9622355
 * Getting pages in different ways:
  * https://gist.github.com/germanny/9399616
  * https://gist.github.com/ericrasch/4723316