• draig

    (@draig)


    I read the documentation, but I still am confused why to use the Block shortcode. It says you can then use shortcodes in the visual editor… but when I tried it by replacing Div’s with Block it added br tags that Div’s in the text editor wasn’t.

    Can you explain more clearly the expected benefit and use?

    Thanks for a great plugin. Finding it has been a revelation after struggling so much to figure out how to make custom loops via php templates.

    https://ww.wp.xz.cn/plugins/custom-content-shortcode/

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

    (@miyarakira)

    Hello,

    The block shortcode was implemented in response to a user request. The reasoning was that when you use HTML in the text editor and then switch to Visual mode, you cannot see the HTML tags like <div> and <a> — making them easy to be accidentally deleted. So, by using block shortcodes, the HTML tags are visible and “protected”.

    The extra <br> tags are caused by automatic formatting of post content. You can enable and use the [raw] shortcode to prevent this. That’s a good point, I’ll include a note in the documentation for HTML blocks.

    To be honest, I haven’t used this feature much except for testing that it works. Usually I put most HTML and shortcodes outside the post, and leave the visual editor for content only.

    Thread Starter draig

    (@draig)

    Thanks for the explanation. That is clearer now… I had assumed that since Block was making it visible in the Visual Editor, that it was also protecting it too…

    Plugin Author Eliot Akira

    (@miyarakira)

    The automatic formatting is useful for text, but doesn’t work well with multi-line shortcodes and not easy to get around. So far, the best solution I found is to use [raw] or pull the shortcodes from outside the editor, as described in the Get Started page of the reference.

    But, your comment made me think. Maybe it makes sense to strip <p> and <br> tags (usually added by auto-format) from inside the block shortcodes by default. In that case, it would be necessary to add them manually with [p] and [br]. Hmm..but that would change its default behavior and could have unexpected results with existing code.. I’ll have to think about it some more.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Block shortcode’ is closed to new replies.