Viewing 4 reply threads
  • Author
    Posts
    • #6296
      cannect
      Member

      Hi,

      I have a custom ‘project_category’ type. I have also a custom ‘project’ type that have some ‘project_category’s attached to it.

      So I thought to retrieve all used project_category’s with:

      
      $filter_category_get = get_posts(array(
              'post_type' => 'project_category',
              'posts_per_page' => -1,
              'post_belongs' => 'NOT NULL', // <- my trick does not work
              'post_status' => 'publish',
              'suppress_filters' => false
          ));
      

      As you can see I do a post_belongs with NOT NULL however this is not gonna work unfortunately.

      How do you accomplish this?

    • #6303
      Jason
      Keymaster

      Hi @cannect!

      I have to ask this first, since you’re calling it a category, would it not work better to be a taxonomy rather than a post type?

      So if I understand correctly, you’re trying to get every project_category post that is related to a project?

    • #6308
      cannect
      Member

      Hi @Jason! You are correct!
      I have never used taxonomies before, maybe a lack of insight what they exactly are. Can they act as a ‘group of things’?

      I am curious how to get this working in Piklist.

    • #6355
      Jason
      Keymaster

      Hi @cannect!

      Sorry for the late reply! Hopefully you’ve already looked into taxonomies a bit more, but in case you haven’t I suggest reading about them here: https://codex.wordpress.org/Taxonomies

      It’s not a Piklist feature; it’s a feature of WordPress itself that allows you to add tag/category type structures to any post type (or even share between post types).

      Hope this helps!

    • #6358
      cannect
      Member

      Thanks for your reply @Jason, taxonomies are indeed the way to go, thanks for pointing at them!

Viewing 4 reply threads
  • The topic ‘Trying to get all categories that has linked posts’ is closed to new replies.