Yeah, much better, however, <p> should still wrap around the quoted text.
Using the example above again…
[inline-quotes]Content here.[/inline-quotes]
The page source result…
<q>Content here.</q>
<p>next paragraph</p>
It should result in…
<p><q>Content here.</q></p>
<p>next paragraph</p>
So
function quote_func($atts, $content = null) {
return '<q><p>' . $content . '</p></q>';
}
add_shortcode('inline-quotes', 'quote_func');
Except NOW you’re not able to do it ‘inline’ anymore, per your example. You can’t do `This is me. [inline-quote]This is Bob[/inline-quote] This is me again.’ Which was your example.
Shouldn’t that be:
function quote_func($atts, $content = null) {
return '<p><q>' . $content . '</q></p>';
}
add_shortcode('inline-quotes', 'quote_func');
Except NOW you’re not able to do it ‘inline’ anymore, per your example.
Agreed – ‘cos now you’ve introduced a block-level element. If this is for your clients, then they’re going to have to learn to use 2 buttons/shortcodes – 1 for inline quotes and 1 for block quotes. And the latter is identical to <blockquote></blockquote> – which means that we’ve come full circle.
Er right, p then q.
And the full circle thing too 🙂
Okay, I should have tested the previous code on my example above, however, I just tried wrapping it around the complete paragraph for testing. So, I went back and just added it to the partial content to be in quotes, and the previous code worked. It wrapped the to-be quoted content in <q>, and the entire paragraph in <p>.
For inline, assuming partial of a paragraph, the following code works:
function quote_func($atts, $content = null) {
return '<q>' . $content . '</q>';
}
add_shortcode('inline-quotes', 'quote_func');
One last thing…when I apply the shortcode via button, it only produces one [inline-quotes]; the end, [/inline-quotes], is not produced. I notice there is </q> added to the code above, but it does not seem to be functioning.
Thanks for the help.
I actually found a better solution, thanks to input and threads found on stackexchange and stackoverflow.
#1 Install TinyMCE plugin
#2 Create shortcode(s), if needed: wordpress-shortcode-tutorial-simple-to-advanced-part-1
#3 Add Functions.php code: how-do-i-add-a-tinymce-row-that-all-users-can-see-instead-of-just-admins
#4 Create JS file: #5 of wordpress-shortcode-tinymce-button-tutorial-part-2