How do I make code box in Wordpress that doesn't mess up the code?

Discussion in 'WordPress' started by hmansfield, May 24, 2010.

  1. #1
    I never thought this would be difficult.
    All I want to do is have a box with code in it that people can copy to paste elsewhere.
    everything I try either strips out the <script> tags and adds < /br> tags, or screws up the code completely so it is worthless.

    I'm just trying to put the code (for copying) for a linked image and I keep getting this:
    Is there some kind of trick to getting this to work in Wordrpess?
    Can anyone help?
     
    Last edited: May 24, 2010
    hmansfield, May 24, 2010 IP
  2. Jessica@GT

    Jessica@GT Peon

    Messages:
    133
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Make sure when you are typing your article out, that you are typing it in HTML & not Visual!

    At the top of the white box where you type all your stuff, on the right top, there should be 2 clickable boxes, one saying Visual, the other Saying HTML. Make sure you have clicked on HTML!
     
    Jessica@GT, May 24, 2010 IP
  3. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #3
    I was doing that, but when I save, the code inside the boxes still messes up.
     
    hmansfield, May 24, 2010 IP
  4. Michelle Waters

    Michelle Waters Member

    Messages:
    74
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Michelle Waters, May 24, 2010 IP
  5. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #5
    So do I need to do that for all of the brackets, or just the 2 at the start and end of the code box?
     
    hmansfield, May 24, 2010 IP
  6. twiztedX3

    twiztedX3 Peon

    Messages:
    163
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You mean the one in Quotes? " " Like those? There should be an option for that but I may be a bit confused what your asking for here.
     
    twiztedX3, May 24, 2010 IP
  7. Michelle Waters

    Michelle Waters Member

    Messages:
    74
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #7
    Your code would look like this in the HTML editor:

    &lt;a&gt;&lt;img&gt;&lt;/a&gt;

    And like this when you post it:

    <a><img></a>

    Naturally, you'd add in the rest of the code, such as the URL...
     
    Michelle Waters, May 24, 2010 IP
  8. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #8
    OK, I had that going before and there was so much extra code there.
    Isn't there a way just to have a simple linked image code, without all the extra stuff?

    I just want my users to be able to copy and paste something simple like
    Isn't there someway to make a box that just simply displays what I type so that it can be copied?
     
    hmansfield, May 24, 2010 IP
  9. Michelle Waters

    Michelle Waters Member

    Messages:
    74
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #9
    The built-in HTML editor does include an option to use special characters without having to know the code. Just click the button with the symbol that looks like an upside down horseshoe.

    This video appears to include information about how to use it:

    http://vimeo.com/11587956
     
    Michelle Waters, May 24, 2010 IP
  10. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #10
    Well...that only covers special characters. I don't need that. I just want a box that I can insert code in (that keeps the code in tact just as a write it) , so users can copy the code and paste it elsewhere.

    Michelle, yes, I have used the code that you suggested and it comes out just like you said, like this <a><img></a>.So that doesn't do me any good if the code disappears when I save it and my readers only see this <a><img></a>...there is nothing to copy.
     
    hmansfield, May 24, 2010 IP
  11. Michelle Waters

    Michelle Waters Member

    Messages:
    74
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #11
    Michelle Waters, May 24, 2010 IP
    hmansfield likes this.
  12. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #12
    Yes Michelle you were right in the beginning. I was doing what you had suggested before and it wasn't working, but then...I remembered that Wordpress MU strips code such as video embeds by default and you have to make adjustments to make it work correctly..that was the problem.

    Once again it was my own "Duh", and not the code.

    I got it now, thank for your help, and everyone.
     
    hmansfield, May 24, 2010 IP
  13. MissDigital

    MissDigital Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    an easier solution to display every scriptlanguage is a plugin named "SyntaxHighlighter Evolved" by Viper007Bond viper007bond.com/wordpress-plugins/syntaxhighlighter/

    This plugin is pretty cool for presenting codesnipets and tutorials
     
    MissDigital, May 25, 2010 IP