Home / Admin / Add WPCode Custom Field Smart Tag
Duplicate Snippet

Embed Snippet on Your Site

Add WPCode Custom Field Smart Tag

Add a custom smart tag for the WPCode scripts metabox that outputs the value of a custom field.

<10
Code Preview
php
<?php
add_filter( 'wpcode_smart_tags', function( $tags ) {
	$tags['custom'] = array(
		'label' => 'Custom',
		'tags'  => array(
			'custom_field_tag' => array(
				'label' => 'Custom Field Tag',
				'function' => 'wpcode_custom_field_tag',
			),
		),
	);
	return $tags;
} );
function wpcode_custom_field_tag() {
	// Replace custom_field_tag below with the meta key of your custom field.
	return get_post_meta( get_the_ID(), 'custom_field_tag', true );
}

Comments

Add a Comment