• Resolved cableghost

    (@cableghost)


    I would like the ability to add opening and ending quotes ‘<q></q>’ using a shortcode.

    I know shortcodes cannot add curling q’s to quoted text, but all I want this shortcode to do is to wrap selected text in <q> brackets.

    So, in a View Page Source DOM, text would look like…

    <p><q>this would be the quoted text</q></p>

    Reasons why…browsers today auto-add the curly q’s upon seeing <q>, and search engines recognize them as specific quoted text, giving them more weight than just using a class to create the affect.

    As far as why creating a shortcode…I can had one simple button to TinyMCE, then I can highlight the text and click the respective button to add the <q> brackets.

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter cableghost

    (@cableghost)

    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>

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    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.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Er right, p then q.

    And the full circle thing too 🙂

    Thread Starter cableghost

    (@cableghost)

    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.

    Thread Starter cableghost

    (@cableghost)

    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

Viewing 6 replies - 16 through 21 (of 21 total)

The topic ‘Add quotes using shortcode’ is closed to new replies.