├── README.md ├── vuecode.js └── wp-vue-tutorial.php /README.md: -------------------------------------------------------------------------------- 1 | # wp-vue-tutorial 2 | This is the code for a tutorial on how to use Vue.js in WordPress. 3 | The tutorial can be found at: https://dev.to/workingwebsites/using-vue-in-wordpress-1b9l 4 | 5 | TLDR; 6 | 1. Create a plugin in WordPress to use the code 7 | 2. Create a shortcode in the plugin 8 | 3. Create your Vue code 9 | 4. Load Vue, then your code file. 10 | 5. Make sure your .js file is loaded after the dom is drawn. 11 | 12 | You're done! 13 | -------------------------------------------------------------------------------- /vuecode.js: -------------------------------------------------------------------------------- 1 | var app = new Vue({ 2 | el: '#divWpVue', 3 | data: { 4 | message: 'Hello Vue!' 5 | } 6 | }) 7 | -------------------------------------------------------------------------------- /wp-vue-tutorial.php: -------------------------------------------------------------------------------- 1 | " 25 | ."Message from Vue: {{ message }}" 26 | .""; 27 | 28 | //Return to display 29 | return $str; 30 | } // end function 31 | 32 | //Add shortcode to WordPress 33 | add_shortcode( 'wpvue', 'func_wp_vue' ); 34 | ?> 35 | --------------------------------------------------------------------------------