{"id":4941,"date":"2023-10-27T12:14:24","date_gmt":"2023-10-27T11:14:24","guid":{"rendered":"https:\/\/harmonweb.com\/blog\/?p=4941"},"modified":"2023-10-27T12:14:25","modified_gmt":"2023-10-27T11:14:25","slug":"what-are-custom-fields-in-wordpress","status":"publish","type":"post","link":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/","title":{"rendered":"What are Custom Fields in WordPress?"},"content":{"rendered":"\n<p>All pages in WordPress have custom fields which contain their own metadata, which includes important information such as the title, description, etc.<\/p>\n\n\n\n<p>WordPress itself uses specific fields to add this data automatically, however, we can also add our own metadata by configuring custom fields in WordPress.<\/p>\n\n\n\n<p>To achieve this, we can do it using a plugin or, as we have been accustomed to most of the time, manually by adding the necessary code ourselves.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"que-son-los-campos-personalizados-de-wordpress\">What are WordPress custom fields?<\/h2>\n\n\n\n<p>Let&#8217;s start by talking about what custom fields are to avoid getting lost.<\/p>\n\n\n\n<p>A field is an element through which information can be added.&nbsp;These can be of different types and forms, such as a list of checkboxes, dates, numbers, text, range slider, etc.<\/p>\n\n\n\n<p>Whatever the case, the information we add using these fields can have endless purposes, although, most of the time, the information will be used as metadata.<\/p>\n\n\n\n<p>Some types of metadata include tags, meta descriptions, categories, etc., although one thing they all have in common is that WordPress already provides those fields, so we can add that content.<\/p>\n\n\n\n<p>Let&#8217;s take an example, and identify some metadata that WordPress itself already includes.<\/p>\n\n\n\n<p>Let&#8217;s analyze the WordPress posts a little. We could find the metadata title, description, featured image, etc. They are considered metadata because they allow us to add information. Do not forget this point, it is very important.<\/p>\n\n\n\n<p>In some cases, we will need to add new metadata, which WordPress does not include by default.<\/p>\n\n\n\n<p>And that is where the custom fields come in, as they will allow us to enter the information we need so that we can associate it with our content.<\/p>\n\n\n\n<p>Finally, we would like to emphasize that <a href=\"https:\/\/wpengine.com\/resources\/wordpress-custom-fields-how-to\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Custom Fields<\/a> and&nbsp;&nbsp;<a href=\"https:\/\/www.cloudways.com\/blog\/wordpress-custom-post-type\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Custom Post Type<\/a>&nbsp;are not the same.<\/p>\n\n\n\n<p>Custom Post Types, on the one hand, correspond to a type of content that has a special format, while Custom Fields are fields that will allow us to add new metadata.<\/p>\n\n\n\n<p>Normally, these Custom Fields that we have created are usually associated with the Custom Post Type, although they can also be used separately, without depending on any type of content.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"agregar-custom-fields-mediante-un-plugin\">Add Custom Fields using a plugin<\/h2>\n\n\n\n<p>There are endless plugins that will allow us to add&nbsp;<strong>custom fields<\/strong>&nbsp;to our&nbsp;<strong>WordPress<\/strong>.&nbsp;However, on this occasion, we will use the plugin called&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/advanced-custom-fields\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Advanced Custom Fields<\/a>, which we can download&nbsp;<strong>for free<\/strong>&nbsp;from the&nbsp;<strong>WordPress repository itself.<\/strong><\/p>\n\n\n\n<p>Once we have it&nbsp;<strong>downloaded, installed,<\/strong> and activated, we will click on&nbsp;custom&nbsp;fields, and then we will add a&nbsp;new group&nbsp;by clicking on&nbsp;add new.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"861\" height=\"399\" src=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-20.png\" alt=\"\" class=\"wp-image-4943\" srcset=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-20.png 861w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-20-300x139.png 300w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-20-768x356.png 768w\" sizes=\"auto, (max-width: 861px) 100vw, 861px\" \/><\/figure>\n\n\n\n<p>Next, we will see a window like the following:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Before analyzing the options presented to us, we will put you in context a little: in the previous article, where we talked about what&nbsp;WordPress custom post types are, we used as an example that on our site we wanted&nbsp;to add series&nbsp;of all kinds but that, we would not use the entries because we are interested in adding extra information such as the&nbsp;<strong>number of seasons<\/strong>&nbsp;and&nbsp;<strong>the score<\/strong>&nbsp;that the series in question has, and, due to these characteristics, we could not consider the series as entries.<\/p>\n\n\n\n<p>For this reason, we decided to create a&nbsp;<strong>type of custom post,<\/strong>&nbsp;but until now we had not started to add those two new characteristics that would differentiate it from the&nbsp;<strong>entries<\/strong>, because, as you already know, we need the&nbsp;WordPress&nbsp;custom fields&nbsp;to add those&nbsp;two&nbsp;metadata.<\/p>\n\n\n\n<p>Now yes.&nbsp;Looking at the previous image, we can see that we have several options.<\/p>\n\n\n\n<p>If we look at them from top&nbsp;to&nbsp;bottom, the&nbsp;first&nbsp;thing we can find is the&nbsp;name&nbsp;of our&nbsp;custom&nbsp;field&nbsp;group, which will be required.&nbsp;Although it does not appear in the image, we decided to name it &#8220;Series&#8221;.<\/p>\n\n\n\n<p>The next thing we can see are the&nbsp;<strong>custom fields<\/strong>&nbsp;that we have added to that group. On this occasion, remember that we only needed two fields: the&nbsp;<strong>score<\/strong>&nbsp;and the&nbsp;<strong>number&nbsp;of seasons<\/strong>, so we do not need to add more fields.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"76\" src=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-21.png\" alt=\"\" class=\"wp-image-4944\" srcset=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-21.png 762w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-21-300x30.png 300w\" sizes=\"auto, (max-width: 762px) 100vw, 762px\" \/><\/figure>\n\n\n\n<p>To\u00a0<strong>add a field<\/strong>, you just have to click on the\u00a0<strong>add field<\/strong>\u00a0option, and a window similar to the following will appear:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"438\" src=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x438.png\" alt=\"\" class=\"wp-image-4945\" srcset=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x438.png 1024w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-300x128.png 300w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-768x329.png 768w, https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/image-22.png 1353w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s see what each of the options does in a little detail:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Field label<\/strong>: It is the name that will appear visually and that will allow us to distinguish it from the rest of the&nbsp;<strong>custom fields.<\/strong><\/li>\n\n\n\n<li><strong>Field name:<\/strong>&nbsp;It must be a single word, you can use hyphens and underscores.&nbsp;It is like the slug of the field, and we will need it when making a query, therefore, we will refer to it by this name.<\/li>\n\n\n\n<li><strong>Field type:<\/strong>\u00a0What type of information will this field contain?\u00a0It can be of any type: text, numbers, emails, links, checkboxes, etc.<\/li>\n\n\n\n<li><strong>Instructions:<\/strong>&nbsp;They appear below the&nbsp;<strong>field label<\/strong>&nbsp;and allow us to give a brief description of our field.<\/li>\n\n\n\n<li><strong>Required:<\/strong>&nbsp;Indicates whether the field is required or not.&nbsp;If so, it must be checked to be able to save\/publish the content.<\/li>\n\n\n\n<li><strong>Default value:<\/strong>&nbsp;Allows you to add a value if one is not given.<\/li>\n\n\n\n<li><strong>Text marker:<\/strong>&nbsp;Text that will appear inside the field if no value has been entered (placeholder).<\/li>\n\n\n\n<li><strong>Prepend:<\/strong>&nbsp;By placing the name of another field, it will appear before it.<\/li>\n\n\n\n<li><strong>Append:&nbsp;<\/strong>&nbsp;Placing the name of another field, will appear after it.<\/li>\n\n\n\n<li><strong>Minimum value:<\/strong>&nbsp;Allows you to add a minimum value to the field.<\/li>\n\n\n\n<li><strong>Maximum value:<\/strong>&nbsp;Allows you to add a minimum value to the field.<\/li>\n\n\n\n<li><strong>Conditional logic:<\/strong>&nbsp;Allows you to add one or more conditions to the field.<\/li>\n\n\n\n<li><strong>Container attributes:<\/strong>&nbsp;It will allow us to add a class or an identifier to the container, in addition to the possibility of giving it a width in percentage.<\/li>\n<\/ul>\n\n\n\n<p>Once this part has been explained, we return to the previous one:<\/p>\n\n\n\n<p>The next section we find is the&nbsp;<strong>Location section,<\/strong>&nbsp;in which we can indicate where our&nbsp;<strong>custom fields<\/strong>&nbsp;are going to be displayed. For this article, as we said previously, we will follow the example of the series, so we will make them appear only in that section&#8230;<\/p>\n\n\n\n<p>In the last option, settings,&nbsp;we see a series of options that can be used to modify our group. On this occasion, we will leave them as they are and click on&nbsp;publish&nbsp;to save our&nbsp;group&nbsp;and&nbsp;custom fields.<\/p>\n\n\n\n<p>If everything has gone well, by accessing the&nbsp;<strong>Series<\/strong>&nbsp;section and adding or editing one, we will be able to see the following:<\/p>\n\n\n\n\n\n<p><strong>And there they are, the series<\/strong>&nbsp;group&nbsp;with the previously created&nbsp;<strong>custom fields<\/strong>:&nbsp;seasons&nbsp;and&nbsp;score.<\/p>\n\n\n\n<p>Very good, we now have our&nbsp;<strong>custom fields<\/strong>&nbsp;created and working, although they will only be visible from our&nbsp;<strong>administration panel<\/strong>.&nbsp;If we want our&nbsp;users&nbsp;to also&nbsp;be able to see&nbsp;this data, we will have to&nbsp;modify&nbsp;the&nbsp;<strong>theme<\/strong>&nbsp;file&nbsp;<strong>in which<\/strong>&nbsp;we&nbsp;<strong>want the information to appear.<\/strong><\/p>\n\n\n\n<p><strong>To do this, we will use the &#8220;get_post_meta&#8221;<\/strong>&nbsp;function ,&nbsp;which follows the following structure:get_post_meta( $post_id, $key = &#8221;, $single = false );<\/p>\n\n\n\n<p>Let&#8217;s see what each of its parameters does:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$post_id:<\/strong>&nbsp;ID of the current post.<\/li>\n\n\n\n<li><strong>$key:<\/strong>&nbsp;The meta key that we want to receive.&nbsp;If one is not specified, it will obtain all those associated with the post we are in (according to the id).<\/li>\n\n\n\n<li><strong>$single:<\/strong>&nbsp;If&nbsp;<strong>true<\/strong>, it will return the first value of the meta key that we specify.&nbsp;If in the previous parameter, we have specified one in particular and not all, the value must be&nbsp;true.<\/li>\n<\/ul>\n\n\n\n<p>The code we have used to add the fields is the following:# We are going to display HTML, so remember to close the PHP syntax if you want to write a &lt;p&gt; tag ?&gt; &lt;p&gt;Seasons: &lt;?php echo get_post_meta( get_the_ID(), &#8216;seasons&#8217;, true); ?&gt;&lt;\/p&gt; &lt;p&gt;Score: &lt;?php echo get_post_meta( get_the_ID(), &#8216;score&#8217;, true); ?&gt;&lt;\/p&gt;<\/p>\n\n\n\n<p>Depending on the theme we are using, we will have to place the code in one part or another, although the part in which we want to place the information received from our fields will also influence it.<\/p>\n\n\n\n<p>Because we must edit the files of our theme, we recommend that&nbsp;<strong>you create a child theme<\/strong>&nbsp;and edit its files, this way, in the case of&nbsp;<strong>updating<\/strong>&nbsp;the&nbsp;<strong>parent theme<\/strong>,&nbsp;the data will not be lost.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"agregar-custom-fields-manualmente\">Add&nbsp;<strong>Custom Fields manually<\/strong><\/h2>\n\n\n\n<p>Next, we will create our own&nbsp;<strong>custom fields<\/strong>&nbsp;without using&nbsp;<strong>any plugins.<\/strong><\/p>\n\n\n\n<p><strong>To do this, we will modify the functions.php<\/strong>&nbsp;file&nbsp;of our active theme, so it is totally recommended, if not mandatory, to make a backup copy of it before starting to modify it.<\/p>\n\n\n\n<p>If you already have your backup ready, let&#8217;s start creating the&nbsp;<strong>custom fields.<\/strong><\/p>\n\n\n\n<p>First of all, we will create the custom fields that we are going to create.&nbsp;To do this, we will use the&nbsp;<strong>\u201cregister_meta\u201d function that&nbsp;<\/strong><strong>WordPress<\/strong>&nbsp;itself&nbsp;offers us and which follows the following structure:<\/p>\n\n\n\n<p>register_meta(&nbsp;&nbsp;$object_type&nbsp;,&nbsp;$meta_key&nbsp;, &nbsp;&nbsp;$args&nbsp;,&nbsp;$deprecated&nbsp;&nbsp;=&nbsp;&nbsp;null&nbsp;&nbsp;)<\/p>\n\n\n\n<p>Let&#8217;s see what each of the parameters is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$object_type:<\/strong>&nbsp;Meta box object type.&nbsp;For example, if we want the fields to appear in all entries, we can leave it as&nbsp;a <strong>post<\/strong>, and if we want a&nbsp;custom post, we must write the&nbsp;<strong>custom post<\/strong>&nbsp;we want.<\/li>\n\n\n\n<li><strong>$meta_key:<\/strong>&nbsp;Meta key that we want to register.<\/li>\n\n\n\n<li><strong>$args:<\/strong>&nbsp;Data used to describe the meta key when registered.<\/li>\n<\/ul>\n\n\n\n<p>Next, and using the previous function, we will create a meta data.&nbsp;The code for our metadata is as follows:add_action(&#8216;init&#8217;, &#8216;series_register_fields&#8217;); function series_register_fields() { register_meta(&#8216;series&#8217;, &#8216;series_seasons&#8217;, &#8216;sanitize_text_field&#8217;); register_meta(&#8216;series&#8217;, &#8216;series_score&#8217;, &#8216;sanitize_text_field&#8217;); }<\/p>\n\n\n\n<p>Well, we already have our fields created, now it is our turn to create a group and introduce these goals into this group.&nbsp;<strong>To do this, we will use the &#8220;add_meta_box&#8221;<\/strong>&nbsp;function&nbsp;which follows the following structure:<\/p>\n\n\n\n<p>add_meta_box(&nbsp;$id&nbsp;,&nbsp;$title&nbsp;,&nbsp;$callback&nbsp;,&nbsp;$screen&nbsp;&nbsp;=&nbsp;&nbsp;null&nbsp;,&nbsp;$context&nbsp;&nbsp;=&nbsp;&nbsp;&#8216;advanced&#8217;&nbsp;,&nbsp;$priority&nbsp;&nbsp;=&nbsp;&nbsp;&#8216;default&#8217;&nbsp;,&nbsp;&nbsp;$callback_args&nbsp;&nbsp;=&nbsp;&nbsp;null&nbsp;&nbsp;)<\/p>\n\n\n\n<p>Let&#8217;s see what each of its parameters does:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$id:<\/strong>&nbsp;Allows both letters and numbers and will be used to uniquely identify the meta box section.<\/li>\n\n\n\n<li><strong>$title:<\/strong>&nbsp;Allows you to indicate the name that our meta box will have.<\/li>\n\n\n\n<li><strong>$callback:<\/strong>&nbsp;Function that will be executed and that will display the HTML code that will go inside our meta box.<\/li>\n\n\n\n<li><strong>$screen:<\/strong>&nbsp;Allows you to indicate what type of content our meta box will be displayed on.&nbsp;The possible values \u200b\u200bare post, page, or custom-posts (the name of the custom post).<\/li>\n\n\n\n<li><strong>$&nbsp;<\/strong><strong>context:<\/strong>&nbsp;Indicates the position in which our meta box will appear.&nbsp;It can take the values: normal or advanced, in case we want it to appear in the same column of the editor or side if we want it to appear on the side.<\/li>\n\n\n\n<li><strong>$priority:<\/strong>&nbsp;Used to indicate the height where the meta box will appear, although it will depend to a certain extent on the plugins we have.&nbsp;Its value can be: core, low, high, or default.<\/li>\n\n\n\n<li><strong>$callback_args:<\/strong>&nbsp;Used to pass parameters that will be used within the function that we use in the&nbsp;<strong>callback parameter.<\/strong><\/li>\n<\/ul>\n\n\n\n<p>The code we have used is the following:add_action(&#8216;add_meta_boxes&#8217;, &#8216;series_meta_box&#8217;); function series_meta_box() { add_meta_box( &#8216;series-meta-box&#8217;, __( &#8216;Additional information &#8211; Series:&#8217;, &#8216;series_textdomain&#8217; ), &#8216;series_meta_box_callback&#8217;, &#8216;series&#8217;, &#8216;normal&#8217;, &#8216;high&#8217;, array( &#8216;arg&#8217; =&gt; &#8216;value&#8217; ) ); } function series_meta_box_callback($post) { echo &#8216;Hello world&#8217;; }<\/p>\n\n\n\n<p>If everything has gone well, we will now have our box available, but, as you can see,&nbsp;<strong>it lacks options to enter data<\/strong>&nbsp;and only shows a message that says &#8220;Hello world.&#8221;<\/p>\n\n\n\n<p>To add the changes and allow these changes to be stored in the database, we must enter the following code in the series_meta_box_callback( $posts ) function:function series_meta_box_callback($post){ ?&gt; &lt;label for=&#8221;series_seasons&#8221; class=&#8221;label&#8221;&gt;Number of seasons:&lt;\/label&gt; &lt;input type=&#8221;number&#8221; name=&#8221;series_seasons&#8221; id=&#8221;series_seasons&#8221;&gt; &lt;label for=&#8221;series_score&#8221; class=&#8221;label&#8221;&gt;Score:&lt;\/label&gt; &lt;select name=&#8221;series_score&#8221; id=&#8221;series_score&#8221;&gt; &lt;option value=&#8221;1&#8243;&gt;1&lt;\/option&gt; &lt;option value=&#8221;2&#8243;&gt;2&lt;\/option&gt; &lt;option value=&#8221;3&#8243;&gt;3&lt;\/option&gt; &lt;option value=&#8221;4&#8243;&gt;4&lt;\/option&gt; &lt;option value=&#8221;5&#8243;&gt;5&lt;\/option&gt; &lt;\/select&gt; &lt;?php }<\/p>\n\n\n\n<p>And now, in order to store the data, we will use the&nbsp;<strong>\u201cupdate_post_meta()\u201d function:<\/strong>update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = &#8221; )<\/p>\n\n\n\n<p>Let&#8217;s see what each of its parameters does:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$post_id:<\/strong>&nbsp;The ID of the current post.&nbsp;Typically, the is stored in the $post_id variable.<\/li>\n\n\n\n<li><strong>$meta_key:<\/strong>&nbsp;Name of the field that usually matches the name of the HTML field we want to store.<\/li>\n\n\n\n<li><strong>$meta_value:<\/strong>&nbsp;Value of the metadata that we are going to save.<\/li>\n\n\n\n<li><strong>$prev_value:<\/strong>&nbsp;Previous value to check before updating.<\/li>\n<\/ul>\n\n\n\n<p>add_action( &#8216;save_post&#8217;, &#8216;series_update_meta&#8217; ); function series_update_meta( $post_id ) { if ( defined( &#8216;DOING_AUTOSAVE&#8217; ) &amp;&amp; DOING_AUTOSAVE ) { return; } if ( get_post_type($post_id) == &#8220;series&#8221; ) { update_post_meta( $post_id, &#8216;seasons&#8217;, $_POST[&#8216;series_seasons&#8217;] ); update_post_meta( $post_id, &#8216;score&#8217;, $_POST[&#8216;series_score&#8217;] ); } }<\/p>\n\n\n\n<p>With the previous code, every time we save our&nbsp;<strong>post type<\/strong>&nbsp;we will check that it is indeed our&nbsp;<strong>post type series<\/strong>&nbsp;and that it has&nbsp;<strong>not<\/strong>&nbsp;been saved through&nbsp;<strong>autosave<\/strong>, but through the button.&nbsp;Finally, the data will be entered into the database.<\/p>\n\n\n\n<p>If what you want is to add a custom field to an entry, the process is much simpler.<\/p>\n\n\n\n<p>To create custom fields in entries, we will go to the entries section, once there, we will click on-screen<strong> options<\/strong>&nbsp;and activate the&nbsp;<strong>custom fields option.<\/strong><\/p>\n\n\n\n<p>Once activated, a box like the following will appear:<\/p>\n\n\n\n<p>To add them, we must click on the drop-down menu, under&nbsp;<strong>name<\/strong>&nbsp;and finally click on&nbsp;<strong>add a custom field.<\/strong><\/p>\n\n\n\n<p>Keep in mind that the field must already exist and that with this option we can only add it to the entries.<\/p>\n\n\n\n<p>To retrieve the values, we will do so using the&nbsp;<strong>&#8220;get_post_meta&#8221; function,<\/strong>&nbsp;as we did in the case of using a plugin.<\/p>\n\n\n\n<p>WordPress&nbsp;<strong>custom fields<\/strong>&nbsp;allow&nbsp;us to add any type of metadata to our pages and posts, and there are very few things we can&#8217;t do with custom fields<strong>.<\/strong><\/p>\n\n\n\n<p>Using a plugin is not a bad option, although if we do, we will always depend on the plugin to maintain our&nbsp;<strong>custom posts.&nbsp;<\/strong>Adding them manually is undoubtedly the best option, as long as it is done in a child theme, although it can be a bit complicated.<\/p>\n\n\n\n<p>And you? Do you know anything else about&nbsp;<strong>custom posts<\/strong>?&nbsp;If so, leave it in the comments.&nbsp;Remember that you can also express your doubts.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>All pages in WordPress have custom fields which contain their own metadata, which includes important information such as&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4963,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[158],"tags":[],"class_list":["post-4941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-troubleshooting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What are Custom Fields in WordPress? | HarmonWeb Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are Custom Fields in WordPress? | HarmonWeb Blog\" \/>\n<meta property=\"og:description\" content=\"All pages in WordPress have custom fields which contain their own metadata, which includes important information such as&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"HarmonWeb Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-27T11:14:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-27T11:14:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"John Adegoke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Adegoke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/\"},\"author\":{\"name\":\"John Adegoke\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/person\\\/e9bc75c3e7e30a261690c47ec872a8fc\"},\"headline\":\"What are Custom Fields in WordPress?\",\"datePublished\":\"2023-10-27T11:14:24+00:00\",\"dateModified\":\"2023-10-27T11:14:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/\"},\"wordCount\":2707,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/customfields.png\",\"articleSection\":[\"Troubleshooting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/\",\"name\":\"What are Custom Fields in WordPress? | HarmonWeb Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/customfields.png\",\"datePublished\":\"2023-10-27T11:14:24+00:00\",\"dateModified\":\"2023-10-27T11:14:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#primaryimage\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/customfields.png\",\"contentUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/customfields.png\",\"width\":1280,\"height\":720,\"caption\":\"custom fields in wordpress\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/what-are-custom-fields-in-wordpress\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What are Custom Fields in WordPress?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\",\"name\":\"HarmonWeb Blog\",\"description\":\"HarmonWeb\",\"publisher\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\",\"name\":\"HarmonWeb\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/cropped-HARMON-WEB-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/cropped-HARMON-WEB-LOGO-2.png\",\"width\":831,\"height\":172,\"caption\":\"HarmonWeb\"},\"image\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/person\\\/e9bc75c3e7e30a261690c47ec872a8fc\",\"name\":\"John Adegoke\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677\",\"contentUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677\",\"caption\":\"John Adegoke\"},\"sameAs\":[\"https:\\\/\\\/harmonweb.com\\\/blog\"],\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/author\\\/harmonweb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are Custom Fields in WordPress? | HarmonWeb Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"What are Custom Fields in WordPress? | HarmonWeb Blog","og_description":"All pages in WordPress have custom fields which contain their own metadata, which includes important information such as&hellip;","og_url":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/","og_site_name":"HarmonWeb Blog","article_published_time":"2023-10-27T11:14:24+00:00","article_modified_time":"2023-10-27T11:14:25+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png","type":"image\/png"}],"author":"John Adegoke","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Adegoke","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/"},"author":{"name":"John Adegoke","@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/person\/e9bc75c3e7e30a261690c47ec872a8fc"},"headline":"What are Custom Fields in WordPress?","datePublished":"2023-10-27T11:14:24+00:00","dateModified":"2023-10-27T11:14:25+00:00","mainEntityOfPage":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/"},"wordCount":2707,"commentCount":0,"publisher":{"@id":"https:\/\/harmonweb.com\/blog\/#organization"},"image":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png","articleSection":["Troubleshooting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/","url":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/","name":"What are Custom Fields in WordPress? | HarmonWeb Blog","isPartOf":{"@id":"https:\/\/harmonweb.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png","datePublished":"2023-10-27T11:14:24+00:00","dateModified":"2023-10-27T11:14:25+00:00","breadcrumb":{"@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#primaryimage","url":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png","contentUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2023\/10\/customfields.png","width":1280,"height":720,"caption":"custom fields in wordpress"},{"@type":"BreadcrumbList","@id":"https:\/\/harmonweb.com\/blog\/what-are-custom-fields-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/harmonweb.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What are Custom Fields in WordPress?"}]},{"@type":"WebSite","@id":"https:\/\/harmonweb.com\/blog\/#website","url":"https:\/\/harmonweb.com\/blog\/","name":"HarmonWeb Blog","description":"HarmonWeb","publisher":{"@id":"https:\/\/harmonweb.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/harmonweb.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/harmonweb.com\/blog\/#organization","name":"HarmonWeb","url":"https:\/\/harmonweb.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2020\/06\/cropped-HARMON-WEB-LOGO-2.png","contentUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2020\/06\/cropped-HARMON-WEB-LOGO-2.png","width":831,"height":172,"caption":"HarmonWeb"},"image":{"@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/person\/e9bc75c3e7e30a261690c47ec872a8fc","name":"John Adegoke","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677","url":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677","contentUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/0843e926db683e41ace2aee54210b841.jpg?ver=1776839677","caption":"John Adegoke"},"sameAs":["https:\/\/harmonweb.com\/blog"],"url":"https:\/\/harmonweb.com\/blog\/author\/harmonweb\/"}]}},"_links":{"self":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/4941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/comments?post=4941"}],"version-history":[{"count":4,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/4941\/revisions"}],"predecessor-version":[{"id":4964,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/4941\/revisions\/4964"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/media\/4963"}],"wp:attachment":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/media?parent=4941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/categories?post=4941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/tags?post=4941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}