function get_service_color() { global $post; $service_color = null; if (is_service_page()) { $parent = array_reverse(get_post_ancestors($post->ID)); $first_parent = get_page($parent[0]); $service_color = get_field('service_color', $first_parent->ID); } return $service_color; }
<div class="search-container pull-right"> <a href="#" id="search-btn"> <i class="fa fa-search"></i> </a> <?php get_search_form(); ?> </div> </div> </header> <?php if (is_service_page()) { ?> <div class="service-page-title" style="background-color:<?php echo get_service_color(); ?> "> <div class="container"> <div class="col-md-12"> <?php the_title(); ?> </div> </div> </div> <?php }
?> "><?php echo esc_html($tag->name); ?> </a> <?php } ?> </div> </div> <?php } } } else { $is_service_page = is_service_page(); // Get the header to show in the sidebar $service_header = ''; if ($is_service_page !== false) { if ($is_service_page === 1) { $service_header = 'Professional Services'; } else { if ($is_service_page === 2) { $service_header = 'Relevant Projects'; } } } else { $service_header = 'Service Categories'; } $post_parent = $is_service_page != false ? get_the_ID() : 0; $service_color = get_service_color();