PHP command to remove header from one page?

8 replies
Hi, using wordpress, I need to remove a "call to action header" (long strip of writing at the top of all pages) from 1 particular page.

When I opened theme PHP files I found this:

Code:
<header id="header-action" class="group">
<div class="margin group">
<?php echo do_shortcode( shortcode_unautop( wpautop( prima_get_setting( 'calltoaction_text' ) ) ) ); ?>
<a class="header-action-button" href="<?php prima_setting( 'calltoaction_url' ); ?>">
<?php prima_setting( 'calltoaction_button' ); ?>
</a>
</div>
</header>

Can I safely edit this to stop it on that one page?

Thanks.
#command #header #page #php #remove
  • Profile picture of the author DJL
    The simplest way, I think, would be to link to a page outside your WordPress installation.
    Signature

    None are more hopelessly enslaved than those who falsely believe they are free.
    --Johann Wolfgang von Goethe, Elective Affinities (1809)

    {{ DiscussionBoard.errors[8411474].message }}
  • Profile picture of the author Lanii
    If its only 1 page url where you dont want headers to show, you can use something like this.
    http://pastebin.com/xewWkGfe

    If you want multiple pages, then create array of URL's and use is_array to check if page url is in that list.
    {{ DiscussionBoard.errors[8411531].message }}
  • Profile picture of the author Beavis
    I have a site that displays html files and needed to only display what was between the <body> tags. I use PHP's DOMDocument class. Sounds like that's what you're trying to do?!?! This code reads in a file (you can also read from a direct stream) and only prints what is in the body tag.

    $doc = new DOMDocument;
    $doc->loadHTML('<?xml encoding="UTF-8">' . MY_HTML_PAGE_SOURCE);
    $body = $doc->getElementsByTagName('body')->item(0);
    print $body->ownerDocument->saveHTML();
    {{ DiscussionBoard.errors[8415052].message }}
    • Profile picture of the author RobinInTexas
      Your best approach would be to use WordPress' conditional functions when editing the php. You would need to determine the page id in order to do that.

      as in
      Code:
      is_page( 42 ) 
      When Page 42 (ID) is being displayed.
      Conditional Tags « WordPress Codex
      Signature

      Robin



      ...Even if you're on the right track, you'll get run over if you just set there.
      {{ DiscussionBoard.errors[8418960].message }}
      • Profile picture of the author rhinocl
        Another approach would be to edit header.php, remove evrything you don't want and save it as header-2.php

        Then just build a new page page template, changing get_header(); to get_header('2');

        and select the new template for that page.
        {{ DiscussionBoard.errors[8419123].message }}
      • Profile picture of the author Edge360
        Originally Posted by RobinInTexas View Post

        Your best approach would be to use WordPress' conditional functions when editing the php. You would need to determine the page id in order to do that.

        as in
        Code:
        is_page( 42 ) 
        When Page 42 (ID) is being displayed.
        Conditional Tags « WordPress Codex
        This is how I would handle this problem!
        {{ DiscussionBoard.errors[8519206].message }}
  • Profile picture of the author kevbo22
    $current_file_name = basename($_SERVER['REQUEST_URI'], ".php");
    if ($current_file_name == "index") {
    //do nothing
    } else {
    include 'header.php';
    }

    Where index would be the file name
    Signature

    The best path to prosperity is free market capitalism!

    {{ DiscussionBoard.errors[8423941].message }}
  • Profile picture of the author KittyPoo
    You dont have to use special command to remove header from one page you should use if statement to check the page name or page where to include header or not. Or you can make seperate header for that page too.
    {{ DiscussionBoard.errors[8518141].message }}

Trending Topics