1

I am trying to statically generate a WordPress site, which means having a list of every url in the site e.g.

routes = [
  '/about-us',
  '/sample-page',
  '/category/uncategorized',
  '/uncategorized/hello-world'
];

I am currently loading three API endpoints I found in the documentation at: https://developer.wordpress.org/rest-api/reference/

/wp-json/wp/v2/pages
/wp-json/wp/v2/categories
/wp-json/wp/v2/posts

But this still doesn't cover all pages in the site... how can I get all pages of the site including tags etc, through the REST API? (without using plugins!)

Bonus points: If you have a recommendation how to resolve the conflict of:

/category/uncategorized
/uncategorized/hello-world

Should really be:

/uncategorized
/uncategorized/hello-world

So that static generation doesn't have missing pages!

Kim T
  • 5,770
  • 1
  • 52
  • 79

1 Answers1

0

I think you are manually going to have to create the URLS for each category that comes back in your categories query. Surely you can get a list, and the create them each on the fly. I know it's not desirable, but what you're trying to do is not exactly cut-and-dry.

EDIT

Maybe look into WP CLI if the REST API isn't working out.

plushyObject
  • 1,123
  • 6
  • 14
  • Yeah I wanted to avoid multiple http requests where possible, but understand there could be alot of pages! here is my code so far: https://github.com/kmturley/angular-universal-wordpress-cms/blob/master/frontend/static.paths.ts#L22 – Kim T Dec 06 '17 at 14:19