Displaying php in a wordpress blog post

Discussion in 'PHP' started by Brewster, Mar 19, 2008.

  1. #1
    Hi all

    Does anyone know of a good plugin for wordpress that will enable me to display php with coloured syntax?

    I've look at some that use geshi, but none of them work well with the graphical post editor.

    Thanks,
    Brew
     
    Brewster, Mar 19, 2008 IP
  2. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Gordaen, Mar 19, 2008 IP
  3. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
  4. ayahhelmy

    ayahhelmy Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Inline php is good, I've been using it since a long time ago.

    But your php code can be seen via "view source" from your browser. I think it's best to create separate php file, ex. whatincluded.php and add only include("the_correct_path/whatincluded.php") on your post.
     
    ayahhelmy, Mar 19, 2008 IP
  5. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #5
    @Gordaen - thanks, this one is quite good, but it does have a few bugs. I can't get it to stop changing <, > and & symbols into &lt; &gt; and &amp; respectively. Any ideas?

    @hasbehas - thanks, but I am only looking to display php code and not execute it

    Brew
     
    Brewster, Mar 19, 2008 IP
  6. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #6
    What version of WP are you using? Also, do you use the rich text editor? I use it on my ecommerce blog, and it definitely works in versions 2 and up. I think that the rich text editor may cause problems with it, but not positive on that one.
     
    jestep, Mar 19, 2008 IP
  7. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Do you mean that if you save and keep editing, the symbols are changed into the entities (e.g., &lt;) in the editing box? I haven't had that problem, but I don't use the "fancy" post editor. If you give me a specific example, I can try it out on mine with and without the WYSIWYG editor and see if I have the same problem or not.
     
    Gordaen, Mar 19, 2008 IP
  8. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #8
    I'm using version 2.3.3

    I am using the visual editor, and I only need to post once (without re-editing) to get the problem behaviour

    Brew
     
    Brewster, Mar 20, 2008 IP
  9. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hmm, not sure what to say. I just tried it on mine and didn't see that problem, but I did experience it adding a space between the "<" and the "?php" when doing a Save and Continue Editing.
     
    Gordaen, Mar 22, 2008 IP
  10. DimitarMK

    DimitarMK Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    DimitarMK, Mar 23, 2008 IP