How to create dynamic pages for categories and Tags in Gatsby wordpress #31605
-
How to implement WordPress gatsby dynamic pages for Categories and Tags |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @pradtv , if you mean dynamic routes as in client side with content being fetched in the users browser directly from WP instead of from Gatsby, you'll want to first check the filesystem route api docs for setting up a dynamic client side route. Check the WPGraphQL docs to see how to query for tags/categories https://www.wpgraphql.com/docs/categories-and-tags. If you don't mean client side and instead mean generating SSR'd pages for these, you can do this the same way you create any page in Gatsby, either using the Filesystem Route API, or with the createPage action. See this doc for more info on that. |
Beta Was this translation helpful? Give feedback.
Hi @pradtv , if you mean dynamic routes as in client side with content being fetched in the users browser directly from WP instead of from Gatsby, you'll want to first check the filesystem route api docs for setting up a dynamic client side route.
Once you've done that and understand how it works you can use a client-side GraphQL library like Apollo or Urql to use the dynamic parts of the url to make a request directly to WPGraphQL.
Check the WPGraphQL docs to see how to query for tags/categories https://www.wpgraphql.com/docs/categories-and-tags.
If you don't mean client side and instead mean generating SSR'd pages for these, you can do this the same way you create any page in Gatsby, ei…