Support » Plugin: Custom Content Shortcode » If page has a parent – 2

  • Resolved studioavanti

    (@studioavanti)


    Late follow-up of this unresolved topic: check if the current page has a parent.
    https://wordpress.org/support/topic/if-page-has-a-parent/

    I found a solution, a bit complicated but it works.
    Could be useful to other people…

    1. Loop to get current page parent
    2. Store parent in a var
    3. Pass var to conditional

    [loop child=this]
      parent slug in the loop: [field slug]<br>
      [set parent_slug][field slug][/set]
    [/loop]
    
    [pass vars]
      Parent slug passed in var: {PARENT_SLUG}<br>
      [if pass='{PARENT_SLUG}' empty=false]
        Has parent!
      [else]
        No parent…
      [/if]
    [/pass]
  • You must be logged in to reply to this topic.