WordPress.org

Ready to get started?Download WordPress

Forums

Edit a Page's Code? (4 posts)

  1. cyberknight8610
    Member
    Posted 3 years ago #

    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?

  2. Tara
    Member
    Posted 3 years ago #

    Admin - Apearance -Editor

  3. cyberknight8610
    Member
    Posted 3 years ago #

    I don't see it for the specific page though

  4. Sidney Harrell
    Member
    Posted 3 years ago #

    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:

    <?php
    /*
    * Template Name: No Ad
    */
    get_header();
    ?>

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags