Support » Fixing WordPress » Edit a Page's Code?

  • How can I edit a pages code on my website? I don’t mean to create a custom page but just to modify a specific one. For instance I have an ad at the top of my pages and post but I don’t want it on one of my pages. How do I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator t-p


    Admin – Apearance -Editor

    I don’t see it for the specific page though

    It is either being placed in the header.php file or in the template file. To find out create an empty file in your theme directory and call it noad.php Add the following lines to it:

    * Template Name: No Ad

    Switch the page that you are interested in to the No Ad template and load the page. It should only load the header. If you can see the ad, then the ad is being placed in the header.php file. If not, then open up the template file that the page was using before.(and switch back to that template) Assuming that the page is using the default template for pages, it would be page.php in your theme directory.
    Find the code that is placing the ad and wrap it so:

    <?php if(!is_page('The title of the No Ad Page')) { ?>
    // The code placing the ad...
    <?php } ?>

    If it is not the No Ad page, then the ads will be displayed. If it is the No Ad page, then the ad code will be skipped. There’s a great plugin that does the same for widgets called widget logic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Edit a Page's Code?’ is closed to new replies.