WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I am writing a post and want to highlight only a couple of characters: like this. How can I achieve this?

share|improve this question
up vote 2 down vote accepted

HTML language includes a special tag for displaying inline code. To apply it to your text, switch to the 'Text' visual editor tab and place the <code> tag before your bit of code, and the </code> tag afterwards.

If you want to use the backtick ` character for highlighting code like you do on Stack Overflow, check out this plugin by Tom McFarlin.

share|improve this answer
thanks great answer.we should always answer in WordPress way if their any.I'm a newbie and learning how to answer on stackoverflow or solve a problem in wordpress way.thanks again. – Ravinder Kumar Jun 7 '13 at 12:37
@Ravs this is the best way for WordPress and everything overall. You shouldn't try and emulate a <code> tag by using a <span> tag. And shortcodes are not supposed to be used for plain HTML, that's what HTML is for – shea Jun 7 '13 at 23:55

you can create a shortcode for this

function ravs_hightlight( $atts, $content=""){
  return '<span class="highlight">'.$content.'</span>';

paste above code in functions.php.

use shortcode in wordpress editer like

[highlight]test for hightlight short code[/highlight]

your html output like

<span class="highlight">test for hightlight short code</span>

give some css to .highlight class

Important Link:


share|improve this answer

This subject has been successfully discussed here, and here.

Bungeshea is right, but you can also and simply add these tags in your text editor (not visual editor):

[sourcecode language='CorrespondingLanguage']
    //Your code goes here
share|improve this answer
That is not Core functionality. In order for that work a plugin, which you do not name, must be installed. Note: both links you post refer to wordpress.com which is a hosted platform that includes some functionality not bundled with the Core and which I have to assume is why that shortcode works on those sites. This is not a viable answer as written. – s_ha_dum May 12 '14 at 2:16
You're right in one point, the links refer to hosted platform, but after many posts readed, these short tags work also on non hosted wordpress sites without plugins... but I will check myself to be sure, thanks for answer @s_ha_dum – Edouard Kombo May 12 '14 at 10:29
I have never known a sourcecode shortcode to be bundled with WordPress. You are mistaken. – s_ha_dum May 12 '14 at 14:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.