Skip to content

Instantly share code, notes, and snippets.

@3mw-support
Last active April 15, 2019 11:12
Show Gist options
  • Save 3mw-support/27a6a34f85ea10e6e06dc5009c400399 to your computer and use it in GitHub Desktop.
Save 3mw-support/27a6a34f85ea10e6e06dc5009c400399 to your computer and use it in GitHub Desktop.
Heading Shortcode
Using the shortcode like this...
[h2]
<h2>Heading Text Here</h2>
<img src="http://placehold.it/400x300">
[/h2]
Would output this....
<div class="heading-wrap h2-wrap">
<h2>Heading Text Here</h2>
<p class="heading-img-wrap"><img src="http://placehold.it/400x300"></p>
</div>
<!-- <p> is auto-wrapped around <img>. If it's impossible to add a class to that <p>, it's not crucial -->
More explanation....
<!-- This line is new, please add it: -->
<div class="heading-wrap h2-wrap">
<!-- Note that the h2-wrap class should be generated by the shortcode. Could be h3-wrap, h4-, etc. -->
<!-- This line is standard WP output. No action needed. -->
<h2>Heading Text Here</h2>
<!-- This line is MOSTLY standard WP output, but I'm hoping you can add the 'heading-img-wrap' class to the <p> -->
<p class="heading-img-wrap"><img src="http://placehold.it/400x300"></p>
<!-- If that's not possible, let me know. It's not 100% crucial. -->
<!-- This line is new, please add it: -->
</div>
<!-- Just closes out the 'div.heading-wrap' above. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment