WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Add quotes using shortcode

[Resolved] Add quotes using shortcode

  • 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 15 replies - 1 through 15 (of 21 total)
  • Why not use <blockquote></blockquote> instead?

    Well, blockquote is much different than <q> quotes, in terms of appearance, how search engines view it, and it is ‘block’, not inline.

    esmi
    Forum Moderator

    @esmi

    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.

    They also recognise the blockquote tag which, given your example above, would be the semantically correct markup.

    Okay, say for a moment I go with blockquote, however, I want to use it inline; could someone provide me the css to allow blockquote to be inline and if possible, auto-add the curly q’s around the text?

    esmi
    Forum Moderator

    @esmi

    Inline? But it’s inside a block level element (<p></p>). Why not use <blockquote<p>this would be the quoted text</p></blockquote> which would be the correct markup?

    For example, see the below. If I use a fair amount of quoting, the layout really looks garbled in blockquoting style, so I wish to elect using it inline.

    HP Looks Panicky as It Dumps Valuable Mobile, Consumer Product … eweek.com: In August 2011, HP announced they were going to drop their consumer-based products, and focus on enterprise client market. Something to think about for future budgets. “Aug 20, 2011 … News Analysis: The first question that comes to mind as HP abruptly changes direction is what were they thinking? The second question has…”

    Is there a way to use blockquotes inline??

    esmi
    Forum Moderator

    @esmi

    Which part are you referencing? The whole quote? Or just the italics?

    Just the italics

    esmi
    Forum Moderator

    @esmi

    OK – so in that context <q?</q> would be correct. But why use a shortcode when that would involve more typing than the correct HTML tags?

    As initially mentioned…

    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.

    esmi
    Forum Moderator

    @esmi

    It should be relatively easy to do using add_shortcode:

    function quote_func($content) {
         return '<q>' . $content . '</q>;
    }
    add_shortcode('quote', 'quote_func');

    http://codex.wordpress.org/Function_Reference/add_shortcode

    Thank you…couple things.

    There was a ‘ missing in your code…corrected code below.

    function quote_func($content) {
         return '<q>' . $content . '</q>';
    }
    add_shortcode('quote', 'quote_func');

    The function creates the shortcode, but when executed, it doesn’t wrap the text, it creates another empty segment, as such…

    <p><q></p></p>

    I’ve tried to figure it out within the link you provided, but I can’t. Any ideas?

    esmi
    Forum Moderator

    @esmi

    You need to use [quote]blah...blah[/quote].

    That’s how I use it, but it acts like there’s no content, like so…

    [inline-quotes]Content here.[/inline-quotes]

    The result…

    “”
    Content here.

    PS. I changed ‘quotes’ to ‘inline-quotes’

    esmi
    Forum Moderator

    @esmi

    Try:

    function quote_func($atts, $content = null) {
         return '<q>' . $content . '</q>';
    }
    add_shortcode('inline-quotes', 'quote_func');
Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘[Resolved] Add quotes using shortcode’ is closed to new replies.