Create new post WordPress programmatically with custom meta fields

How can you create and insert new posts containing already filled Advanced Custom Fields programmatically into your database?

  1. Say you have an ACF group with 3 fields each of a different type
    • description (type Text)
    • image (type Image)
    • categories (type Taxonomy)
  2. prepare a basic post

  1. insert post and keep the created post id

  1. then update values of custom fields using the post id

… Or it can be done using the following code:

To enter a new post for a custom type

 

After inserting the post, a post id will be returned by the above function. Now if you want to enter any post meta information w.r.t this post then following code snippet can be used.

enter image description here

WordPress display the_meta() of in custom page

I have some meta values on my wordpress custom page that I need to be displayed in a table. Is there any way I can do that.

Here’s the code I’m using now: <?php the_meta(); ?>

And this is what it shows:

enter image description here

I want to do something like:

enter image description here

I found out that:

the_meta() is located in wp-includes/post-template.php

This makes the output:

 

So it’s not recommended to edit files in that folder because of the wordpress update.

You can make a table in html and display each value individually, like this:

 

Here‘s the documentation or https://codex.wordpress.org/Using_Custom_Fields