Blocking line of code

by Mmfh
6 replies
Hey there,

I'm wondering if there is a way to easily shut down a line of code in a wordpress theme. Doing some tweaking to see what I like and what I don't like and I would like to shut down certain lines of code instead of removing them.

If I could just put some <tag> at the beginning of the line so it is ignored, then if I don't get the result I want I can just remove that tag again and its back the way it was.

No deleting or copy and paste and making sure I remember where I removed it from if I want to put it back.

Say for example I want to remove the sidebar, a little code blocker to see what happens before I actually remove it would be good.

Thanks very much!

Mm
#blocking #code #line
  • Profile picture of the author mywebwork
    WordPress themes (and WordPress itself) are PHP files containing a combination of PHP and raw HTML codes. So you could probably just comment out the lines you don't need.

    If you have a standard bit of text you include with the comments you can search for it later and remove them all easily (assuming you're using a proper editor and not the one thats included in the WordPress dashboard).

    Bill
    {{ DiscussionBoard.errors[1752504].message }}
    • Profile picture of the author fr0ke
      Originally Posted by mywebwork View Post

      WordPress themes (and WordPress itself) are PHP files containing a combination of PHP and raw HTML codes. So you could probably just comment out the lines you don't need.

      If you have a standard bit of text you include with the comments you can search for it later and remove them all easily (assuming you're using a proper editor and not the one thats included in the WordPress dashboard).

      Bill
      Specifically, to comment something out in php, you can put a double slash at the beginning of the line, or wrap multiple lines in /* */

      like so:

      PHP Code:
      // this is a single line comment and will not be executed

      /* 
      This is a block comment and can wrap multiple lines.
      */ 
      For HTML, you use the following for block comments:

      Code:
      <!--
      This is an HTML comment and will be ignored by the browser.
      -->
      {{ DiscussionBoard.errors[1752956].message }}
      • Profile picture of the author Jeremy Morgan
        You can comment anything out you want, but be careful not to break the loop. If you comment out any <div> tags, make sure they are all self contained, meaning you aren't just commenting out a closing div or an opening div only. This will break the page. Done it many times, which is why I mention it.
        Signature
        Jeremy Morgan, Software Developer / SEO
        Check out my Programming Blog for news, tips, and tutorials
        {{ DiscussionBoard.errors[1753371].message }}
        • Profile picture of the author mojojuju
          I'll comment stuff out, delete it completely, or replace lines that I wish to. But I make a backup copy of the file first, usually in the format of OriginalFilename.php.bak.DateOfBackup.

          So if I'm going to tweak a file called index.php, I'll back it up as index.php.bak.100215 first, and then I can carelessly edit away at the original file without worries.
          Signature

          :)

          {{ DiscussionBoard.errors[1754937].message }}
  • Profile picture of the author Mmfh
    Thanks guys for your replies! I'm using the editor that is in the wordpress dashboard though. When you are in the editor your different pages appear on the right.

    I always use static sites and never blogs so I like to get rid of the sidebar with the comments and links and all that stuff that just doesn't look good.

    I will use the info given to let me try to remove things to see what happens before I actually delete anything.

    Thanks very much!

    Mm
    Signature

    Changing Life for my family "One" Click at a time.

    {{ DiscussionBoard.errors[1756911].message }}
  • Profile picture of the author mywebwork
    When editing themes I usually find its best to:

    A) Make a backup copy of the entire theme before editing

    B) Download the theme files to my local workstation and use a proper text editor to do the work. The convenience of using a good set of tools more than makes up for the short delay in having to FTP the files up to the server to check the results.

    Working on a local server or XAMPP installation of WordPress helps too.

    Best of luck with your modifications.

    Bill
    {{ DiscussionBoard.errors[1757023].message }}

Trending Topics