• Skip to the primary navigation.
  • Skip to the content.
Beans Theme Framework
Menu
  • Themes
  • Showcase
  • Docs
  • Support
  • Community
  • Documentation
  • Code snippets
  • Code reference

beans_get_post_meta

  • Function
  • Since 1.0.0
  • Updated on October 12, 2016
  • Packaged under API / Post Meta

Get the current post meta value.

This function is a shortcut of get_post_meta().

beans_get_post_meta( string $field_id, mixed $default = false, $post_id = false )

Return: (mixed) Saved data if exist, otherwise default value set.

Parameters

NameTypeRequiredDefaultDescription
$field_idstringtrue-The post meta id searched.
$defaultmixedfalsefalseThe default value to return of the post meta value doesn't exist.
$term_idintfalse-Overwrite the current post id.

Source

function beans_get_post_meta( $field_id, $default = false, $post_id = false ) {

	if ( ! $post_id ) {
		$post_id = ! ( $id = get_the_id() ) ? beans_get( 'post' ): $id;
	}

	$post_meta = get_post_meta( $post_id );

	if ( isset( $post_meta[ $field_id ] ) ) {
		return get_post_meta( $post_id, $field_id, true );
	}

	return $default;

}
Filters

Code reference categories

  • Admin
  • Initialize
  • Assets
  • Render
  • Structure
  • API
    • Actions
    • Compiler
    • Fields
    • Filters
    • HTML
    • Image
    • Layout
    • Options
    • Post Meta
    • Templates
    • Term Meta
    • UIkit
    • Utilities
    • Widgets
    • WP Customize
  • Fragments

Get notified when new stuff is released, and more...

Here at BeansPress, we roast hot code on a weekly basis. Follow us on Twitter to make sure you don't miss anything!

Follow @BeansPress

“If you haven't found the magic in Beans, you haven't looked far enough!”

© Beans  |  Contact  |  DonateFounded by Thierry Muller, co-maintained by Tonya Mork
Beans project is no longer maintained, thanks for your support for so many years. Stay awesome!