Meta-data is taken care of with key/value sets. The key is the name of the meta-data component. The value is the data that will show up in the meta-data list on every individual post that the data is related with.
Function Reference : add_post_meta()
For Example : We’ll include two custom fields, one called “At present Reading” and the other “Author Name”. The accompanying guidelines will show how to add this data to a post utilizing Custom Fields.
- After you have composed your post, look down to the titled Custom Fields.
- To create a new Custom Field called “At present Reading”, enter the text “At present Reading” (without the quotes) in the text entry field titled Name.
- The recently made Key (“At present Reading”) should now be given a Value, where the name will be given as, “Kitchen Nightmare”. Sort “Kitchen Nightmare” in the Value field, again without the quotes.
- Click Add Custom Field button to save this custom information for that post.
On your new post, you can add a new book name to your meta-data. In the Custom Fields section, the Key will now feature a pull down list with the previously entered Custom Fields. Choose “At Present Reading” and then enter the new book you are reading in the value.
You need to create a new “KEY”, after which you can assign a value to that key for every post. You can also assign more than one Value to a key, for a post.
With a Custom Field added to the post, it’s a great opportunity to show your books name to the world. To show the Custom Fields for every post, utilize the the_meta() layout tag. The tag must be put inside The Loop with a specific end goal to work. Many individuals include the_meta() layout tag to the finish of their post or in their Post Meta Data Section.
Here is a fundamental case of utilizing the tag:
<?php the_meta(); ?>
<li><span class=’post-meta-key’>At Present Reading:</span>Kitchen Nightmare</li>
The template tag automatically puts the entire meta-data into a CSS style called post-meta.
The key is in a span called post-meta-key so you can style it in your style sheet.
For any further queries feel free to Contact Us we would be glad to help you.