Tony Schaefer
Tony Schaefer

Reputation: 1

How do I excluding INDEX or Home page in PHP Code?

I know nothing about PHP. I have the code below to show next and prev at the bottom of each page, with <-|-> as a separator but I don't want it on the home/index page.

<div align="center" >
<?php echo previous_page_not_post(); ?> <-|->  <?php echo next_page_not_post(); ?>
</div>

How can I do this?

Upvotes: 0

Views: 104

Answers (1)

Tommaso Bertoni
Tommaso Bertoni

Reputation: 2381

You can add an if statement like this:

<div align="center">
<?php
    if (basename($_SERVER['PHP_SELF']) != "index.php") {
        echo previous_page_not_post()." <-|-> ".next_page_not_post();
    }
?>
</div>

(Look at get current php page name)

Upvotes: 1

Related Questions