• Resolved Jimmy Symmonds

    (@jimmy-symmonds)


    Hello ??
    Is there a simple way to list parents of current post (hierarchical custom post)? The output would look similar to breadcrumbs. Nothing in the forums either that I can find. I have found documentation and code (below) for children to be listed but not parents.

    [loop type=page orderby=title]
      [field title]
      [-loop parent=this orderby=title]
        Child page: [field title]
      [/-loop]
    [/loop]

    Have I missed it somewhere?
    Thank you

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

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

    (@miyarakira)

    This function doesn’t exist yet. The difficulty I see is that it’s hierarchical, so there must be a way to trace back the parents to the top, then loop through each generation downward:

    Top parent -> child -> grandchild -> current post

    I’ll think about how this can be implemented, and will let you know.

    Thread Starter Jimmy Symmonds

    (@jimmy-symmonds)

    Thank you Eliot.

    Plugin Author Eliot Akira

    (@miyarakira)

    I added this feature in the newest update.

    For example, if the current post is a grandchild page:

    [loop child=this include=this]
      [if not first] > [/if][field title]
    [/loop]

    This will display: Parent > Child > Grandchild.

    Please see the documentation under Main > Loop > Parent/Child.

    Thread Starter Jimmy Symmonds

    (@jimmy-symmonds)

    Excellent. Than you Eliot. Been playing with it and it’s almost 100%

    I am using the code below in template for CPT to get output of

    plant use: parent > child > grandchild

    plant use: [loop type=plant_use child=this include=this][if not first] > [/if][field title-link][/loop]

    Works perfectly except on parent page where output is

    plant use: (blank)

    instead of

    plant use: parent

    Thank you
    Jimmy

    Plugin Author Eliot Akira

    (@miyarakira)

    Oops, you’re right. I corrected this in the newest update, to handle the case when the current post is a top-level parent.

    Thread Starter Jimmy Symmonds

    (@jimmy-symmonds)

    It works! ??
    Haven’t tried it in reverse, but the typical breadcrumbs-like setup works as imagined. Very useful. Thanks Eliot.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Breadcrumb-like output – shortcode to list parents of hierarchical custom posts’ is closed to new replies.