<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Metabox Archives | Effortless Custom Fields</title>
	<atom:link href="https://ecfwp.com/tag/metabox/feed/" rel="self" type="application/rss+xml" />
	<link>https://ecfwp.com/tag/metabox/</link>
	<description>World’s least confusing custom fields plugin</description>
	<lastBuildDate>Sat, 17 Feb 2024 10:29:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://ecfwp.com/wp-content/uploads/2023/08/cropped-fav-icon-1-32x32.png</url>
	<title>Metabox Archives | Effortless Custom Fields</title>
	<link>https://ecfwp.com/tag/metabox/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are Custom Fields in WordPress?</title>
		<link>https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/</link>
					<comments>https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Paras Ralhan]]></dc:creator>
		<pubDate>Thu, 15 Feb 2024 12:01:00 +0000</pubDate>
				<category><![CDATA[WordPress Custom Fields]]></category>
		<category><![CDATA[Custom Fields]]></category>
		<category><![CDATA[Metabox]]></category>
		<guid isPermaLink="false">https://ecfwp.com/?p=4163</guid>

					<description><![CDATA[<p>Custom Fields in WordPress refers to any input field—it can be of the type: text, textarea, dropdown, checkbox, checkboxes, gallery, date, time, etc.— that can hold some custom data related&#8230; </p>
<p class='read-more'><a href='https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/' title='Read More about What are Custom Fields in WordPress?' class='read-more' data-toggle='tooltip' data-placement='right' >Read More <i class='fa fa-angle-double-right' aria-hidden='true'></i></a></p>
<p>The post <a href="https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/">What are Custom Fields in WordPress?</a> appeared first on <a href="https://ecfwp.com">Effortless Custom Fields</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="large">Custom Fields in WordPress refers to any input field—it can be of the type: <strong>text</strong>, <strong>textarea</strong>, <strong>dropdown</strong>, <strong>checkbox</strong>, <strong>checkboxes</strong>, <strong>gallery</strong>, <strong>date</strong>, <strong>time</strong>, etc.— that can hold some custom data related to post, page, category, or any other type of content. The data that goes into these custom fields can be fetched with utility functions provided by WordPress.</p>



<p class="large">Clients always love to have a separate place to enter their custom data. By creating custom fields for them, you empower your clients to control their content without messing up its presentation.</p>



<h2 class="wp-block-heading">Three ways to create Custom Fields</h2>



<ol class="smooth-scroll wp-block-list">
<li><a href="#inbuilt-custom-fields" data-type="internal" data-id="#inbuilt-custom-fields">Through WordPress Inbuilt Custom Fields</a></li>



<li><a href="#through-custom-coding">Through Custom Coding</a></li>



<li><a href="#through-plugins">Through Plugins</a></li>
</ol>



<h3 class="wp-block-heading h2" id="inbuilt-custom-fields">Through WordPress Inbuilt Custom Fields</h3>



<p>These are available only for post types (if supported) and not for any other content type. For categories, tags, taxonomies, profile, customizer, you have to create custom fields by next two methods.</p>



<p><strong>How to make inbuilt custom fields visible: </strong>follow steps as shown below:</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;69cd19b2ed2e6&quot;}" data-wp-interactive="core/image" data-wp-key="69cd19b2ed2e6" class="wp-block-image size-full wp-lightbox-container"><img fetchpriority="high" decoding="async" width="1500" height="914" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://ecfwp.com/wp-content/uploads/2024/02/enable-wordpress-inbuilt-custom-fields.jpg" alt="3 Steps to make inbuilt custom fields visible" class="wp-image-4164" srcset="https://ecfwp.com/wp-content/uploads/2024/02/enable-wordpress-inbuilt-custom-fields.jpg 1500w, https://ecfwp.com/wp-content/uploads/2024/02/enable-wordpress-inbuilt-custom-fields-300x183.jpg 300w, https://ecfwp.com/wp-content/uploads/2024/02/enable-wordpress-inbuilt-custom-fields-1024x624.jpg 1024w, https://ecfwp.com/wp-content/uploads/2024/02/enable-wordpress-inbuilt-custom-fields-768x468.jpg 768w" sizes="(max-width: 1500px) 100vw, 1500px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			aria-label="Enlarge"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.imageButtonRight"
			data-wp-style--top="state.imageButtonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<p><strong>Where they show up: </strong>see below:</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;69cd19b2ed5e2&quot;}" data-wp-interactive="core/image" data-wp-key="69cd19b2ed5e2" class="wp-block-image size-full wp-lightbox-container"><img decoding="async" width="1500" height="1026" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://ecfwp.com/wp-content/uploads/2024/02/wordpress-inbuilt-custom-fields.png" alt="WordPress Inbuilt Custom Fields appears at maked location" class="wp-image-4165" srcset="https://ecfwp.com/wp-content/uploads/2024/02/wordpress-inbuilt-custom-fields.png 1500w, https://ecfwp.com/wp-content/uploads/2024/02/wordpress-inbuilt-custom-fields-300x205.png 300w, https://ecfwp.com/wp-content/uploads/2024/02/wordpress-inbuilt-custom-fields-1024x700.png 1024w, https://ecfwp.com/wp-content/uploads/2024/02/wordpress-inbuilt-custom-fields-768x525.png 768w" sizes="(max-width: 1500px) 100vw, 1500px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			aria-label="Enlarge"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.imageButtonRight"
			data-wp-style--top="state.imageButtonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<h4 class="wp-block-heading h3">Pros and Cons of Inbuilt Custom Fields</h4>



<p><strong>Pros:</strong></p>



<ul class="wp-block-list">
<li>Available by default. Nothing extra need to be installed or done to create them.</li>
</ul>



<p><strong>Cons:</strong></p>



<ul class="wp-block-list">
<li>The inbuilt custom fields are pretty basic and limited. You can only save simple text data in them.</li>



<li>They make interface look messy.</li>



<li>You have to create these custom fields for each entity (post, page, etc.)</li>
</ul>



<h3 class="wp-block-heading h2" id="through-custom-coding">Creating fields through Custom Coding</h3>



<p>This is the most tedious way to create custom fields. If you are a programmer and you love to build custom solution for your clients, only then choose this route, otherwise prefer using some plugin. It is a lengthy process and it requires you to have understanding of PHP, WordPress, HTML, and CSS. Let’s see how to create custom fields for <strong>post_type = ‘post’</strong>.</p>



<p>WordPress has a concept of <strong>MetaBoxes</strong>. A <strong>MetaBox </strong>is a container that can hold any content, and we want it to hold our custom fields.</p>



<p>To create a MetaBox for <strong>post_type = ‘post’,</strong> see code below:</p>



<pre class="wp-block-code language-php"><code>&lt;?php
/**
 * ===============================
 * Register meta box(es).
 * ===============================
 */
add_action( 'add_meta_boxes', 'your_prefix_register_meta_boxes' );

function your_prefix_register_meta_boxes () {

	add_meta_box( 
		'meta-box-id', 
		__( 'Meta Box Label', 'textdomain' ), 
		'your_prefix_display_fields', 
		'post' 
	);
	
}</code></pre>



<h4 class="wp-block-heading">Use following code to render fields into this MetaBox:</h4>



<pre class="wp-block-code language-php"><code>&lt;?php
/**
 * ===========================================
 * Meta box display callback.
 *
 * @param WP_Post $post — Current post object.
 * ===========================================
 */
function your_prefix_display_fields( $post ) {

	// Add an nonce field so we can check for it later.
	wp_nonce_field( 'your_prefix_custom_box', 'your_prefix_custom_box_nonce' );

	// Use get_post_meta to retrieve an existing value from the database.
	$value = get_post_meta( $post-&gt;ID, 'your_prefix_first_custom_field', true );

	// Display the form, using the current value.
	?&gt;
	&lt;label for="your_prefix_first_custom_field"&gt;
		&lt;?php _e( 'Your First Custom Field', 'textdomain' ); ?&gt;
	&lt;/label&gt;
	
	&lt;input type="text" id="your_prefix_first_custom_field" name="your_prefix_first_custom_field" value="&lt;?php echo esc_attr( $value ); ?&gt;" /&gt;
	&lt;?php

}
</code></pre>



<h4 class="wp-block-heading">To save fields, use below code:</h4>



<pre class="wp-block-code language-php"><code>&lt;?php
/**
 * ===========================================
 * Save meta box content.
 *
 * @param int $post_id Post ID
 * ===========================================
 */
add_action( 'save_post', 'your_prefix_save_meta_box' );

function your_prefix_save_meta_box( $post_id ) {

	/*
	 * We need to verify this came from the our screen and with proper authorization,
	 * because save_post can be triggered at other times.
	 */

	// Check if our nonce is set.
	if ( ! isset( $_POST&#91;'your_prefix_custom_box_nonce'] ) ) {
		return $post_id;
	}

	$nonce = $_POST&#91;'your_prefix_custom_box_nonce'];

	// Verify that the nonce is valid.
	if ( ! wp_verify_nonce( $nonce, 'your_prefix_custom_box' ) ) {
		return $post_id;
	}

	/*
	 * If this is an autosave, our form has not been submitted,
	 * so we don't want to do anything.
	 */
	if ( defined( 'DOING_AUTOSAVE' ) &amp;&amp; DOING_AUTOSAVE ) {
		return $post_id;
	}

	// Check the user's permissions.
	if ( 'page' == $_POST&#91;'post_type'] ) {

		if ( ! current_user_can( 'edit_page', $post_id ) ) {
			return $post_id;
		}

	} else {

		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return $post_id;
		}

	}

	/* OK, it's safe for us to save the data now. */

	// Sanitize the user input.
	$your_first_field_value = sanitize_text_field( $_POST&#91;'your_prefix_first_custom_field'] );

	// Update the meta field.
	update_post_meta( $post_id, 'your_prefix_first_custom_field', $your_first_field_value );	

}</code></pre>



<h4 class="wp-block-heading">To get the field value in your template, use following code:</h4>



<pre class="wp-block-code language-php"><code>&lt;?php
$value = get_post_meta( get_the_ID(), 'your_prefix_first_custom_field', true );

// When you echo the value, use proper escaping, for eg.:
?&gt;
&lt;h3&gt;&lt;?php echo esc_html($value); ?&gt;&lt;/h3&gt;
&lt;?php</code></pre>



<h4 class="wp-block-heading h3">Pros and Cons of creating Custom Fields by Custom Coding</h4>



<p><strong>Pros:</strong></p>



<ul class="wp-block-list">
<li>Extreme Flexibility.</li>



<li>You learn in inner working of how custom fields works under the hood.</li>
</ul>



<p><strong>Cons:</strong></p>



<ul class="wp-block-list">
<li>A long and tedious process.</li>



<li>You have to handle security issues that itself is challanging.</li>



<li>Code you write should not conflict with others. You have to use your custom prefixes everywhere.</li>
</ul>



<h3 class="wp-block-heading h2" id="through-plugins">Creating fields through Plugins</h3>



<p>This is the most recomended way to create custom fields in your various WordPress admin screens. They let you build custom fields with tiny effort when compared to custom coding. There are lots of free WordPress plugins available in market that will solve most of your problems. </p>



<p>Each plugin comes with its own way of creating and managing custom fields. Most of Custom Field plugins has their Free and Pro versions. </p>



<h4 class="wp-block-heading">Below are some of the Custom Fields Plugins:</h4>



<ol class="wp-block-list">
<li><strong><a href="https://ecfwp.com/">Effortless Custom Fields</a>: </strong>This plugin is developed by our team, and we have done everything to remove all limitations that we experienced with other WordPress plugins available in the market. It has 32 free field types. Only one field—Repeater—is in PRO. The other things in PRO are layout fields: Accordion and Tabs. Effortlessness as promised is delivered. </li>



<li><a href="https://wordpress.org/plugins/advanced-custom-fields/" target="_blank" rel="noreferrer noopener nofollow"><strong>Advanced Custom Fields: </strong></a>This is the most popular plugin in WordPress. It has around 34 field-types, 4 of which are available in PRO version. If you need to use Gallery field, you need to use their PRO version.</li>



<li><strong><a href="https://wordpress.org/plugins/meta-box/" target="_blank" rel="noreferrer noopener">MetaBox</a>:</strong> It lets you customize custom fields with much flexibility. Their free version don&#8217;t allow you to create fields in WordPress admin. You have to use their online fields code generator. Then copy the code to your theme—a messy process. You can create unlimited custom meta boxes and fields with it.</li>



<li><a href="https://wordpress.org/plugins/pods/" target="_blank" rel="noreferrer noopener"><strong>Pods:</strong></a> It lets you create not just Custom Fields, but also Custom Content Types. It has a lot but is complex.</li>



<li><a href="https://wordpress.org/plugins/bonzer-custom-fields/" target="_blank" rel="noreferrer noopener"><strong>Bonzer Custom Fields:</strong> </a>This is also a good plugin. It lets you create many types of custom fields quickly and assign at many locations. It’s great if you don’t need huge number of fields. It become messy when number of fields goes beyond certain limits. On positive side: It&#8217;s quick, light, and does the job. It offers 15 field types and has no PRO version.</li>
</ol>
<p>The post <a href="https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/">What are Custom Fields in WordPress?</a> appeared first on <a href="https://ecfwp.com">Effortless Custom Fields</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://ecfwp.com/wordpress-custom-fields/what-are-custom-fields-in-wordpress/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
