• Resolved zitron81

    (@zitron81)


    Hello,

    I’m trying to obtain a list of my categories, with all the subcategories, but I don’t understand how to do it…

    Are nested “for each” possible?

    Or should I use “pass”? (if so, how? I don’t understand how it works)

    I can get the subcategories using “parent” inside and each, but I have to manually write the parent name… I would like a loop to retrieve all the parents and then loop on each of them to retrieve their children.

    Is it possible?

    https://www.ads-software.com/plugins/custom-content-shortcode/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Currently, there’s no way to retrieve child taxonomies inside a [for each] loop. It’s a good idea, I’ll try to think of a solution. I imagine something like..

    [for each="category"]
      Category: [each name]
      [-for each="child"]
        Subcategory: [-each name]
      [/-for]
    [/for]

    It may take me a few days to implement it, but I’ll let you know.

    Thread Starter zitron81

    (@zitron81)

    It would be amazing ??

    Let me know if you can do it…

    Thanks!

    I would also love to see how to list categories and sub categories in a list that has the url to the categories.

    And related to this is something I have been trying to figure out but am having issues:
    I want to show the category of the post that is being viewed and have the category name be a url to the category. This is all I have so far:
    Posted in [content taxonomy="project_category"] | [comment count] Comments

    This is a great plugin, good job.

    Plugin Author Eliot Akira

    (@miyarakira)

    In the latest update, I added a feature for looping through child terms. You can use it like this:

    [for each="category" parents="true"]
      Category: [each]
      [-for each="child"]
        Subcategory: [-each]
      [/-for]
    [/for]

    Also, a new parameter to display the term name with a link to its archive: [each link].

    Outside the [for] loop, you can display it like:

    [taxonomy project_category field="link"]
    Thread Starter zitron81

    (@zitron81)

    It works ??

    …but I can’t use a loop anymore inside of it…

    would it be too much to ask for something like:

    [for each="category" parents="true"]
      Category: [each]
      [-for each="child"]
        Subcategory: [-each]
        [loop type="post"]
          [field title]
        [/loop]
      [/-for]
    [/for]

    Only if you do have time for it… ??

    I’m using it with woocommerce products actually, not categories and posts… and the loop works, but it doesn’t filter the category. It gives me all the products.

    It would be very useful to me, but I don’t know if it’s something easy to fix or not ??

    I’ll use the nested “for each” anyway in a different page ??

    Thank you so much!!!

    perfect, this works for my loop. thank you

    Thread Starter zitron81

    (@zitron81)

    I think there’s something wrong with the [loop] inside any [for each] and not just with the nested [-for each]…

    It doesn’t pass the category to the loop as it did before.

    Plugin Author Eliot Akira

    (@miyarakira)

    Oops, you’re right – I changed the way [for each] stores the current term, to support nesting, and [loop] needed to reflect the change as well. I fixed this in the latest update, so [loop] gets filtered correctly, nested or not.

    Thread Starter zitron81

    (@zitron81)

    I get a fatal error now O_o

    this is my shortcode, very basic:

    [for each="category" parents="true"]
      [each link]
      [-for each="child"]
        [-each link]
        [loop type="post"]
          [field link]
        [/loop]
      [/-for]
    [/for]

    This is the error I get on the page:
    Fatal error: Cannot access private property CCS_ForEach::$index in /home/content/p3pnexwpnas06_data01/17/2311217/html/wp-content/plugins/custom-content-shortcode/includes/core/loop.php on line 743

    It actually gives me the same error in a normal [for each], non only in the nested one.

    Thread Starter zitron81

    (@zitron81)

    @fabio
    I need a list of custom taxonomies actually.
    I use CustomShortCode to loop through taxonomies and products that I created with WooCommerce.

    And it’s nice actually, because I can use it in a lot of different scenarios (like with normal categories and posts).

    It looks like your plugin only work on standard categories… so it wouldn’t suite my needs.

    Ah yes, you’re right!

    I can’t help you with your issue, anyway good luck!

    Plugin Author Eliot Akira

    (@miyarakira)

    Sorry about the hiccup, zitron81 – I thought it was a quick fix, and didn’t do enough testing. I made an update to correct this mistake.

    Thread Starter zitron81

    (@zitron81)

    Yep, now it works!!! ??

    Thanks a lot! ??

    Plugin Author Eliot Akira

    (@miyarakira)

    Great, thanks for confirming that it works. It’s a brand new feature, so please let me know if you encounter any issues.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘How can I get a category list with sub-categories?’ is closed to new replies.