Edit MetaBox Views via API?

Support MB Views Edit MetaBox Views via API?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #47936
    OliverOliver
    Participant

    Hello, if it possible to edit a View via API? And where is the data for Template, CSS, Javascript stored?

    I thought I might be able to do this using WordPress API as I thought it might just be a custom post. But I tried using the API to GET using post type 'mb-views' but nothing gets returned.
    So making a request like: /wp-json/wp/v2/mb-views or /wp-json/wp/v2/mb-views/POST-ID

    I can see in the URL when I go to views this: post_type=mb-views but this doesn't seem to be a registered post type.

    My use case is I want to be able to programmatically get / update the Template, CSS, Javascript for a MB view. If I go to my wp_posts table I can find post for the View there - although I can only see the content for the Template under post_content

    #47943
    PeterPeter
    Moderator

    Hello Oliver,

    Each view template is a post, stored in the table wp_posts. If you want to access the view post via Rest URL, you can modify the post type mb-views, and enable Rest API for this post type

    'show_in_rest' => true

    Then you can access the view post with the URL format:
    https://site.com/wp-json/wp/v2/mb-views/post-id-123

    Refer to this topic https://wordpress.stackexchange.com/questions/342540/is-there-possible-way-to-modify-custom-post-type
    and documentation https://developer.wordpress.org/reference/hooks/register_post_type_args/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.