• Is there a way to access the parent block type/name from within a shortcode function?

    Trivial, semi-nonsensical example to illustrate:

    add_shortcode('trivial_example', function() {
      if (parent_block['wp:shortcode']) { return 'x' }
      elseif (parent_block['wp:paragraph']) { return 'y' }
    }
    • This topic was modified 4 years, 9 months ago by aliceonfire.
Viewing 1 replies (of 1 total)
  • The nature of shortcodes is that they are not nestable.
    The shortcode handler function is PHP, so there is no editor context to give you block information. Besides, what if there are no blocks, just HTML?

Viewing 1 replies (of 1 total)
  • The topic ‘access enclosing block properties’ is closed to new replies.