Wordpress XML-RPC - > ACF带中继器

时间:2018-06-06 10:01:34

标签: python wordpress advanced-custom-fields xml-rpc

我很乐意使用ACF(高级自定义字段)通过XML-RPC推送一些附件,但我无法弄清楚如何构建我要发送接口的数据数组。

def simple_post():
    wp = Client(xmlrpc_url, username, password )
    wp.call(GetPosts())
    wp.call(GetUserInfo())
    post = WordPressPost()
    post.title = 'My new title'
    post.content = 'This is the body of my new post.'
    post.date = datetime(2018, 4, 11, 20, 34, 2)
    post.status = 'publish'
    post.terms_names = {
                        'post_tag': ['test', 'firstpost'],
                        'category': ['Introductions', 'Tests'] 
                        }
    post.custom_fields = [{'key': 'allega_file', 
                            'value': [
                                      {'key' :' _file', 'value': 228 },
                                     ]
                            }] 
    # 228 is the id of the media uploaded, but where i've to explain wich filetype and other information? 
    post_num = wp.call(NewPost(post))
    print(post_num)

这是我从ACF界面看到的,也许它有所帮助。 enter image description here

我查看了官方支持页面,但对此几乎没有任何疑问 有任何想法吗? TNX

0 个答案:

没有答案