bshiluk / vue-wordpress

Use Vue.js and the WP REST API to build WordPress themes as SPAs with dynamic routing, HMR for development, SEO enabled, and SSR capable. Demo:
http://vue-wordpress-demo.bshiluk.com
491 stars 112 forks source link

Newbie trying to make sense of it. #18

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi. I will intensely work with this for the next few weeks (or at least, this is what I highly hope to do if my manager allows the project to continue).

I am a beginner in Vue, like, really nub. I know the basics, I understand the MVC model, the directives and stuff like that. My issue:

Is anybody here available for a couple of hours of chit chat on this subject? I'm seeking for help to understand the following:

There are surely more How to's but I haven't hit them yet.

Even if no response is given to this issue, I am willing to discover those and log them here; for new people that might be using this and find their selves in this situation.

Hopefully it's approved for display, Kind regards.

shubhra14 commented 4 years ago

I'd highly recommend buying this course. It covers all the nitty gritties and is easy to follow. Also, doesn't cost much (always some offer going on). There are some free courses as well in there that I haven't looked into.

ghost commented 4 years ago

I'd highly recommend buying this course. It covers all the nitty gritties and is easy to follow. Also, doesn't cost much (always some offer going on). There are some free courses as well in there that I haven't looked into.

Yep I'll probably do that after finishing 'Up and running with Vue' from O'Reilley, but at the moment my main concern and focus is to understand the in-betweens of wordpress and vue with this RADL instance.

I've created a new endpoint in functions.php for categories with some certain ID, but that doesn't seem to be enaugh to pull it into my Vue.

ghost commented 4 years ago

I'd highly recommend buying this course. It covers all the nitty gritties and is easy to follow. Also, doesn't cost much (always some offer going on). There are some free courses as well in there that I haven't looked into.

Yep I'll probably do that after finishing 'Up and running with Vue' from O'Reilley, but at the moment my main concern and focus is to understand the in-betweens of wordpress and vue with this RADL instance.

I've created a new endpoint in functions.php for categories with some certain ID, but that doesn't seem to be enaugh to pull it into my Vue.

Following up with this. I've managed to insert the data into the store so I can use it with all components. However, did not managed to succeed with a new endpoint; I receive the "code": "rest_no_route", "No route was found matching the URL and request method", when I try to access a custom route.

Steps:

  1. 'retreats' => RADL::callback('retreats'), -> instantiated the __VUE_WORDPRESS__ store with a new structure of mixed values
  2. the callback is a function that queries wordpress and returnes the posts + appended to them the acf fields, inserted within the function. the code is as follows:
function retreats(){
    $retreats = [];
    $args = array(
        'post_type' => 'post',
        'category_name' => 'retreats'
    );
    $the_query = get_posts($args);
    foreach ($the_query as $key => $post){
        $retreats[$key] = $post;
        $retreats[$key]->acf = get_fields($post->ID); 
    }
    return $retreats;
}

to quick-view the data in a raw format I'm using this.$store.state.retreats. I'll follow up with actions, mutations and getters for those, hopefully :)