Adding value to Custom field using xml-rpc

I wanted to create wordpress post using xmlrpc, for that I am using python wordpress-xmlrpc.

when i am trying to pass custom field for example price it works well but when I use _price it does not get inserted to the database.

Read More

does anyone has faced issue like me?

I have refered this forum thread.

Here is my code for reference,

from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost, EditPost
from wordpress_xmlrpc.methods.users import GetUserInfo
from wordpress_xmlrpc import WordPressPost

wp = Client('http://localhost/xmlrpc.php', 'admin', 'a')

post = WordPressPost()

post.title = 'My post'
post.content = 'This is a wonderful blog post about XML-RPC.'
post.post_status = 'publish'
post.post_format = 'quote'

post.custom_fields = [{'key': 'price','value': 2}]
post.custom_fields.append({'key': "_price", 'value': 22})
post.id = wp.call(NewPost(post))
print post.id

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. This is an old question but maybe somebody will find my answer useful:
    basically meta fields starting with underscore prefix _ are private and will no be shown on admin screen.

    Here you have answer for similar question: https://wordpress.stackexchange.com/questions/183858/difference-between-meta-keys-with-and-without#answer-183860

    The underscore prefix are private, these meta fields will be hidden and will not be shown as custom fields in the post backend screens. Those meta fields without the underscore prefix are public fields and shows up as custom fields in the post screens