• Resolved dfumagalli

    (@dfumagalli)


    Hello,

    I have created a simple block as follows:

    <div>
    <div style=”float: right;”>%%div_contents%%</div>
    </div>

    I had to use the editor in HTML mode else it’d “interpret” the div and would also add extraneous nbs and <p>.

    Later on, I type this in the editor:

    [contentblock id=1 div_contents=”[slideshow]”]

    Upon saving the post or switching between HTML and Visual, I get a broken content block image that is missing the last two characters: “] and the same two characters appear next to the right of the content block image.
    Saving and viewing the page shows the whole content block doing nothing and all you see are those “] character.

    I don’t know if this has anything to do with this WP shortcode API notice:

    http://codex.wordpress.org/Shortcode_API

    The shortcode parser does not accept square brackets within attributes. Thus the following will fail:

    [tag attribute=”[Some value]”]

    http://wordpress.org/extend/plugins/global-content-blocks/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author benz1

    (@benz1)

    Hi dfumagalli and apologies for the delay in responding.

    I past this onto my developer who responded as follows:

    You cannot use square brackets inside the block parameters, like that.
    What I suggest is using something along these lines:

    The block code could be:

    <div>
    <div style="float: right;">
    
    [%%div_contents%%]
    
    </div>
    </div>

    and then, for the parameter, he could use:

    [contentblock id=1 div_contents="slideshow"]

    That would produce :

    <div>
    <div style="float: right;">
    
    [slideshow]
    
    </div>
    </div>

    in the end, so that would be good.

    The problem with the above might be that he wants to set more than a shortcode inside that div. In that case, he could use multiple parameters, or multiple content blocks, or even use the ability to embed blocks into others.

    Hope this helps.

    Regards,
    Benz1

    Thread Starter dfumagalli

    (@dfumagalli)

    @benz1

    Thank you for your reply, you are most kind!

    Your fix indeed works but I needed a more general block able to digest both regular code and short codes. It’d become a content aligmnent template I used for a whole section of my website regardless of the parameter contents. That’s why I’d pass the whole square brackets.
    I hoped to find a way to “escape” the brackets so the WordPress shortcode parser would not get confused.

    Anyway, in the end I have done a solution like yours. It’s less general but it gets the job done.

    Best regards,
    dfumagalli

    Plugin Author benz1

    (@benz1)

    Glad you managedto get it working.

    Thread Starter dfumagalli

    (@dfumagalli)

    Glad to see such a caring Developer 😀
    Keep the good work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Global Content Blocks] Shortcode in block seems to not work’ is closed to new replies.