最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rest api - Use the backbone.js client to save custom post type meta

programmeradmin1浏览0评论

So I have this small piece of code that renders an array of IDs:

const selected = this.$data.list.selected;
function get_ids(input, field) {
    const output = [];
    for (let i=0; i < input.length ; ++i)
        output.push(input[i][field]);
    return output;
}
const result = get_ids(selected, "id");

Now inside my JS, I want to be able to use the backbone.js API that WordPress provides to save it to my employee custom post type as a post meta.

So let's say that my result output is [343, 3532] - I want to be able to save that array as a "apps" post meta under employees.

I know examples showed that it would be something like const test = new wp.api.models.Employee().fetch and then save, but it sounds super confusing since I don't have a specific post, and would just like to save the post meta.

Based on these examples, does anyone know how I could do that?

发布评论

评论列表(0)

  1. 暂无评论