Blocking line of code

by 6 replies
8
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
#programming #blocking #code #line
  • 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
    • [ 1 ] Thanks
    • [1] reply
    • 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.
      -->
      • [ 1 ] Thanks
      • [1] reply
  • 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
  • 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

Next Topics on Trending Feed

  • 8

    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.