Ready to get started?Download WordPress


[resolved] Code comments not working in Theme Editor (4 posts)

  1. captal
    Posted 3 years ago #

    When I try and edit any of my theme files by entering comments //,# or /* ... */ they just show up as text on my website. I'm guessing there is a pretty easy fix to this but I'm brand new to WordPress and I can't seem to figure it out.

    I'm using 2.9.2 (tried the 3.0beta and had the same problem). I've tried using different themes, including the default, and have no plug-ins active.

    What am I doing wrong? I realize I could upload file changes via FTP, but I thought that was one of the points of the Theme Editor- being able to change your code via browser.

  2. Daniel J
    Posted 3 years ago #

    Hi captal,

    The comment characters you listed are for PHP and CSS. If you are adding comments to XHTML files, you need to use the arrow sequence:


    If you are editing at the code level, anything between the two arrows will not appear on your published page / post.


  3. captal
    Posted 3 years ago #

    Well I thought I was editing PHP files (they have a .php extension). I tried the arrows under the 3.0beta version and I don't think they worked, but they are working for my files now. Thanks for the help.

  4. Daniel J
    Posted 3 years ago #

    I'm glad it worked!

    Files with a .php extension can contain a combination of XHTML and PHP (as well as other languages). If you are commenting inside XHTML code the arrows will do the trick. You will want to use the corresponding comment code depending on the coding language as it appears in your web page. Unfortunately there isn't a universal comment-type for all languages.

    <?php get_search_form(); ?> /* The '<?php', and '?>' tags denote php */
    <form><h2>Search this site:</h2></form> <!-- The '<form>', and '</form>' tags denote XHTML -->

    The example above shows how you can combine the two languages and use different comment types in the same document.

Topic Closed

This topic has been closed to new replies.

About this Topic