PHP command to remove header from one page?

by 8 replies
10
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.
#programming #command #header #page #php #remove
  • The simplest way, I think, would be to link to a page outside your WordPress installation.
  • 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.
  • 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();
    • [1] reply
    • 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
      • [2] replies
  • $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
  • 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.

Next Topics on Trending Feed