Learn WordPress Custom Fields

Custom Fields

  • add_post_meta()
  • update_post_meta()
  • delete_post_meta()
  • get_post_custom() – Gets all key/value data for current post.
  • get_post_custom_values() – Get only those values associated with particular key and current post.
  • get_post_custom_keys() – Gets the list of keys for current post.
  • the_meta() -Unordered list of post’s meta-data.
    • <?php the_meta; ?>
  • get_post_meta() – You can specify the post id you want to pull custom data from and whether to only return first result.
  • get_the_id() – Retrieve the ID of the current item in the WordPress loop.
  • To add support in a custom post type, list in supports’ $args:
    • ‘supports’ => array(‘title’, ‘editor’,’thumbnail’,’custom-fields’)
  • Permissions
    • current_user_can()
  • sanitize_text_field() – Replaces dangerous characters with HTML-safe characters.
  • wp_nonce_field()
  • wptexturize() – Takes a string and changes any unfriendly characters into their HTML friendly equivalents.
  • add_meta_box() – Adds a meta box to the admin interface.
  • have_posts() – Are there any posts remaining in the DB that match the specified criteria to pull?