Frontity release: Support for Custom Post Types & Custom Taxonomies

We have added support for Custom Post Types and Custom Taxonomies!

You just need to configure them in your frontity.settings.js – inside the wp-source package – adding the following options:

  • postTypes: array of post type definitions with the properties type, endpoint and archive (more info here).
  • taxonomies: array of taxonomy definitions with the properties taxonomy, endpoint, postTypeEndpoint and params (more info here).

An example using both options would be:

{
  name: "@frontity/wp-source",
  state: {
    source: {
      api: "https://test.frontity.io/wp-json",
      postTypes: [
        {
          type: "movies", // type slug
          endpoint: "movies", // REST API endpoint
          archive: "/movies-archive" // link where this custom posts are listed
        }
      ],
      taxonomies: [
        {
          taxonomy: "actors", // taxonomy slug
          endpoint: "actor", // REST API endpoint
          postTypeEndpoint: "movies", // endpoint from which posts from this taxonomy are fetched
        }
      ]
    }
  }
}

After that, you can cosume and use these Custom Post Types and Taxonomies the same way you were doing with posts and categories or tags before.


Another important updates:

  • We have added the create-package command to our CLI. With this command, you can add empty packages to your project and start developing themes and other type of packages from scratch.

    It has the following syntax:

    npx frontity create-package [name] [--namespace <value>]
    

    NOTE: If you don’t specify name or namespace you will be prompted to do so, as these values are mandatory.

    The newly created package is ready-to-use – just add it to your frontity.settings.js as the rest of packages.

  • We have added the --dont-open-browser option to the dev command (the name is self-explanatory).

  • We have fixed a problem in the <Image> component when using native lazy-loading in Chrome if the height prop was not present.

  • We also made some improvements to mars-theme (#203) and created the package type-declarations (#211).

Features

  • cli: add --dont-open-browser option to dev (6ae037c)
  • frontity: add create-package command (#218) (eac88fd)
  • wp-source: add postTypes and taxonomies arrays to state (8f8fce3)

Bug Fixes

  • image: add height prop and set loading=auto if no height is present (9870414)
  • core: delete package name from merged store (7428a90)
  • typescript: update to latest version (a89b11c)

Versions

 - @frontity/components@1.1.13
 - @frontity/connect@1.0.3
 - @frontity/core@1.3.0
 - @frontity/file-settings@1.1.4
 - frontity@1.4.1
 - @frontity/hooks@1.1.12
 - @frontity/html2react@1.1.13
 - @frontity/mars-theme@1.2.2
 - @frontity/router@1.0.16
 - @frontity/source@1.0.15
 - @frontity/tiny-router@1.0.16
 - @frontity/type-declarations@1.0.1
 - @frontity/types@1.1.2
 - @frontity/wp-source@1.4.1
 - @frontity/yoast@1.1.4
6 Likes

What’s the command to update frontity? Do we just run npm update in the root of our webserver or is there an npx command we should use?

Updating npm packages is not very straightforward so we made a small guide in our docs: https://docs.frontity.org/guides/keep-frontity-updated

Let me know if that helps :slight_smile:

1 Like

Yes it does. Works great! Thanks!

2 Likes

A post was split to a new topic: How do I add endpoint to the state?