plugin development - dynamic vue widget inside custom post

Im fairly new to WP development and am trying to create a plugin that generates a widget depending on the settings set i

Im fairly new to WP development and am trying to create a plugin that generates a widget depending on the settings set in the custom post type. The widget is written in vue.js, and i would like to supply it with data from the WPDB (that i download and refresh using the plugin).

So a user can create a new custom post, set variables (example: URL of where the data is) and other settings inside that post, and then use the shortcode to display the widget.

I've created the plugin, read about custom post types and the REST API and created the frontend Widget.

My problem is this:

  • How do i get Data from the DB to the frontend (vue.js)? Can i use the REST API for the WPDB?
  • How can i use a custom post type to "feed" information into my widget? I assume i can just get the data from the WPDB about my custom post (storing the settings as part of the custom post), but that just brings me back to the first question.
  • Do i use a "post template" to "inject" my widget, or is there something else for that?

Im fairly new to WP development and am trying to create a plugin that generates a widget depending on the settings set in the custom post type. The widget is written in vue.js, and i would like to supply it with data from the WPDB (that i download and refresh using the plugin).

So a user can create a new custom post, set variables (example: URL of where the data is) and other settings inside that post, and then use the shortcode to display the widget.

I've created the plugin, read about custom post types and the REST API and created the frontend Widget.

My problem is this:

  • How do i get Data from the DB to the frontend (vue.js)? Can i use the REST API for the WPDB?
  • How can i use a custom post type to "feed" information into my widget? I assume i can just get the data from the WPDB about my custom post (storing the settings as part of the custom post), but that just brings me back to the first question.
  • Do i use a "post template" to "inject" my widget, or is there something else for that?
Share Improve this question asked Jul 2, 2019 at 11:56 fogxfogx 1011 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0
  • How do i get Data from the DB to the frontend (vue.js)? Can i use the REST API for the WPDB?

The REST API works for this, or you could include the data in the HTML as JSON or a window variable

  • How can i use a custom post type to "feed" information into my widget? I assume i can just get the data from the WPDB about my custom post (storing the settings as part of the custom post), but that just brings me back to the first question.

The REST API, this is pretty much the same question as above. Note that fetching posts in WP via WPDB is highly unusual, and is commonly considered a code smell and bad practice. WP_Query is a far superior/easier method

  • Do i use a "post template" to "inject" my widget, or is there something else for that?

You could do that, but it would be easier to build a block or shortcode

Keep in mind, that retrieving the data and putting/embedding something in a post are on topic, but Vue.js is offtopic, you'll need to consult Vue.js communities on how it's used.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745351845a4623880.html

相关推荐

  • plugin development - dynamic vue widget inside custom post

    Im fairly new to WP development and am trying to create a plugin that generates a widget depending on the settings set i

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信