0
Welcome Guest! Login
0 items Join Now

Gantry 5 Particles - Custom Post Types & Taxonomies

    • Jain's Avatar
    • Jain
    • Jr. Rocketeer
    • Posts: 26
    • Thanks: 0

    Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • Hi guys,

      I've been using Gantry 5 for ages and I love it but I've suddenly run into a fairly large problem.

      I'm working on a website that uses a number of custom post types, each with their own custom taxonomy and terms.

      Now I can't use any of the particles that feed Wordpress content because they only apply to Posts and Categories.

      I modified the contentarray particle to fetch articles from a particular post type and one of its taxonomies by setting them in the .html.twig, but that means I would have to create individual particles for each post type, as well as modifying all of the other wordpress content particles and making a new version of each of those for each post type too.

      Is there a better way to do this? Basically what I'd like to be able to do is select a Post Type and select a Taxonomy Term from with the particle and filter the content like that.

      Thoughts?
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13481
    • Web Designer/Developer

    Re: Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • Add extra fields in the yaml and use those in the twig file to select what you need.

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
    • Jain's Avatar
    • Jain
    • Jr. Rocketeer
    • Posts: 26
    • Thanks: 0

    Re: Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • How do I add fields to select a post type and a taxonomy term?
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13481
    • Web Designer/Developer

    Re: Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • Just add custom fields in the yaml file to do whatever you want and then use the values of those fields in your selection in the twig file (the code that retrieves the posts). Look in Gantry 5 docs for how to add fields to the yaml for the particle and the various field types). You will be creating overrides for all particles that retrieve the WP posts - there's no way around that. But at least by using the fields values in the particle instances you can be more selective about what is retrieved.

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
    • Jain's Avatar
    • Jain
    • Jr. Rocketeer
    • Posts: 26
    • Thanks: 0

    Re: Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • I already know how to add YAML fields and use the fields. The question is specific to custom post types and taxonomies. There is no documentation on how to set the YAML to list either of those
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13481
    • Web Designer/Developer

    Re: Gantry 5 Particles - Custom Post Types & Taxonomies

    Posted 5 years 8 months ago
    • Ok, clearly I am not understanding you but as this is a developer question rather than about any RT product per-se I think you might be better to ask your question in the gitter chat for Gantry 5 where other developers may be better able to assist you.

      https://gitter.im/gantry/gantry5

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.

Time to create page: 0.044 seconds