Building a PWA vuejs app with wordpress API – Part 4

Building a PWA vuejs app with wordpress API – Part 3

In part 3 we will be looking at categories (or archives in wordpress terminology)

At this point, its good to look into the wordpress API – fortunately there is excellent documentation available here:
The specific endpoint we are interested in is the ‘post’ endpoint:

The first edit we are going to make, is to add a route:

    path: '/category/:id',
    name: 'category_id',
    component: () =>
        import ( /* webpackChunkName: "post" */ './views/CategoryID.vue')

Showing posts from an individual category

Create a new file (CategoryID.vue) and add the following content:

  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
      v-for="post in posts"

// @ is an alias to /src
import axios from 'axios'
import PostSmall from '@/components/PostSmall.vue'

export default {
  name: 'category_id',
    return {
      posts: []
  components: {
    axios.get('' + this.$
    .then(response => {
      this.posts =

This is almost exactly the same as the Home file, except that we aren’t getting the latest posts, we are getting the latest posts in a specific category

Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Part 7 Adding Cordova to an existing Vue App

Leave a Reply