Is it possible to edit the code for one of your wordpress pages?

by 7 replies
8
Hey guys quick question

Say I add a page to my word press site and then I want to edit the code on that page individually so I can remove and add certain things on that page but it does not effect the others.

Is this possible?

For example, on one particular page I don't want the side bar, but the rest I do.

- Thanks
#programming #code #edit #pages #wordpress
  • Yes. You can accomplish this through the use of templates. Your theme may already have this available. There is a great deal of information about this on Goo-Gull.
  • Off course, here is the option: yourdomain/wp-admin/theme-editor.php
    • [2] replies
    • First you'll have to figure out the template of the page you want to modify if is something other than page.php.

      Then you can basically copy/paste the code in to a new file called page-nosidebar.php or something similar and at the top of the file you'll need to give your new file a template name so it shows up when you go to make a new page.

      Check out the WP Codex for how to set up the template name.
    • If you want to crash your site when you make a coding error, by all means use the internal theme editor.

      If you make an error in a theme file - and even experienced coders do - it can cause your whole site to go down, including the internal editor. So you've made a goof, saved the file, crashed the site, now you have no way to fix it because you can't even get to the editor.

      When you're modifying theme files, plugin files, etc., do it the smart way - download the file to your computer using FTP. Make a backup so you have a known working copy. THEN make your changes, upload, and test.
  • I may also depend on what you want to do with that page, and where you want to edit.

    If, for instance, you're looking to edit solely the "content" of the page, and not your header, say, then you may just not need a template.

    On the other hand, if you want to change something more permanent, like a header, sidebar, or footer, then you'll need to either build a custom page, or a template.

    What exactly do you want to change?
  • Steve,

    I almost agree, but cPanel --> Legacy File Manager -->upload file and replacing the file that was edited will fix that and allow you to try again.

    Always have your control panel open just for this issue, as I learned the hard way.

    I edit on a home server now though, so if you have an extra system install some form of unix on it and edit right there.
  • If you need to make a landing page for a particular page, what you do can do is create a page, and when you edit it, you will see the "id" of the page that you create. This unique identifier will allow you to override your theme, and make for a different display for just that ID.

    Meaning, that you can copy your page.php file, and if your ID was 1321, you would copy the file to the name...
    page-1321.php
    and you would then be able to edit the template for that particular page.

Next Topics on Trending Feed