Search code examples
phpwordpressif-statementorbit

php wordpress is_site if statement - multiple orbit sliders


I would like to use multiple, different orbit sliders which are displayed in header. I tried to build if statement using is_page(ID) but it seem not working, after uploading this in my header.php page went blank, only top navigatioan appeared. Can you help me out and improve this code?

 <?php
     if (is_page(112){
      get_template_part('partials/slider3');
     } 
     elseif (is_page(110)) {
      get_template_part('partials/slider2');
     }

?>

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Support Center</title>

<?php wp_head(); ?>
</head>
<body <?php body_class( );?>>


<?php get_template_part('partials/topbar'); //Topbar navigation ?>
<!-- OFF CANVAS FOUNDATION NAVIGATION -->  
<div class="off-canvas-wrap"> 
<div class="inner-wrap">
<nav class="tab-bar show-for-small">
<section class="left-small">
<a href="#" class="left-off-canvas-toggle menu-icon"><span></span></a>
</section>
<section class="middle tab-bar-section">
<h1 class="title"><i class="fi-first-aid"></i> 
<a href="<?php bloginfo( 'url' );?>">Support Center</a></h1>
</section>
</nav>
<?php get_sidebar('off-canvas'); ?>

Solution

  • try this:

    $page_id = get_queried_object_id();
    if ($page_id == 112) {
       get_template_part('partials/slider3');
    } elseif ($page_id == 110) {
       get_template_part('partials/slider2');
    }
    

    By the way, your forgot a ) here: if (is_page(112){ must be if (is_page(112)) {