Skip to content

Instantly share code, notes, and snippets.

@wisecrab
Last active August 27, 2015 15:41
Show Gist options
  • Select an option

  • Save wisecrab/aa715c148af3c640bab0 to your computer and use it in GitHub Desktop.

Select an option

Save wisecrab/aa715c148af3c640bab0 to your computer and use it in GitHub Desktop.
Easy to use functions for getting access to custom meta data for posts and custom posts.
/*****************************************************
*** Get all taxonomy terms for a post ***
*****************************************************/
get_the_term_list( $post->ID, 'taxonomy_name' ); //Returns links
get_the_term_list( $post->ID, 'taxonomy_name', '', ', ', '' ); //Returns links separated by commas
strip_tags(get_the_term_list( $post->ID, 'taxonomy_name' )); //Returns text
/*****************************************************
*** Get custom fields for a post ***
*****************************************************/
//Get custom fields from a post
get_post_meta( $post->ID, 'custom_field', true); //true returns string, false returns array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment