Title: Problem when posting source code
Last modified: August 22, 2016

---

# Problem when posting source code

 *  [quents](https://wordpress.org/support/users/quents/)
 * (@quents)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/)
 * Hi,
 * I don’t know if the problem is about the theme, but when I try to add a source
   code to my post like the following piece of code, It doesn’t work and
 * [code language="cpp"]
    #include <iostream> #include <string> #include <fstream
   > #include <vector> #include <sstream> using namespace std; struct FileRead{ 
   void readFromFile(); vector<vector<string>> person; }; [/code]
 *  It views the code like that:
 * How can I solve this issue?
 * Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632400)
 * Hi quents. Does it do the same thing in one of the default WP themes like Twenty
   Fifteen?
 *  Thread Starter [quents](https://wordpress.org/support/users/quents/)
 * (@quents)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632406)
 * I tried it now and yes, It does the same thing. That means this isn’t about the
   theme. But I have no idea what it is about, I couldn’t see anyone experience 
   a problem like that.
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632410)
 * Are you using a custom shortcode?
 *  Thread Starter [quents](https://wordpress.org/support/users/quents/)
 * (@quents)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632416)
 * I don’t think so. How could it be related to this?
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632420)
 * What you’re trying to do won’t work without a custom shortcode. Using `[code]`
   with square brackets isn't proper HTML and so WordPress tries to parse the parts
   in angled brackets (`<iostream>`, `<string>`, etc.) as HTML, which fails. You
   probably need to get a syntax highlighting plugin to do what you're trying to
   do.
 *  Thread Starter [quents](https://wordpress.org/support/users/quents/)
 * (@quents)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632421)
 * But, If I type a code like that (without brackets):
 * [code language="cpp"]
    string line; [/code]
 * The problem still occurs.
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632428)
 * What’s happening is that when you use square brackets like you’re doing, WordPress
   interprets that text as a shortcode, which is essentially a short way of inserting
   HTML and/or JavaScript into a post. But WordPress doesn’t know about the shortcode
   you’re trying to use, so it just displays the text as is. You probably need to
   get a syntax highlighting plugin to do what you’re trying to do.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Problem when posting source code’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/hueman/3.7.27/screenshot.png)
 * Hueman
 * [Support Threads](https://wordpress.org/support/theme/hueman/)
 * [Active Topics](https://wordpress.org/support/theme/hueman/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/hueman/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/hueman/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [source-code](https://wordpress.org/support/topic-tag/source-code/)

 * 7 replies
 * 3 participants
 * Last reply from: [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/problem-when-posting-source-code/#post-5632428)
 * Status: not resolved