-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservice-template.php
72 lines (59 loc) · 2.1 KB
/
service-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/*
Template Name: Service template
Template Post Type: page
*/
?>
<?php
$id= get_the_id();
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
$h2 = substr($content, 0, strpos($content, '</h2>') );
$allParags = explode("</h2>", $content);
unset($allParags[0]);
$parag = implode($allParags);
$heading = strip_tags($h2);
$pageSlug = get_post_field( 'post_name', get_post() );
$subservicesArgs = array(
'post_type' => 'subservices',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'menu_order',
'meta_query' => array(
array(
'key' => 'service_page',
'value' => $pageSlug
)
)
);
$subservices = new WP_Query($subservicesArgs);
?>
<?php get_header(); ?>
<?php require 'includes/page-buffer.php'; ?>
<?php require 'includes/banner.php'; ?>
<div class="section section-service-blurb">
<div class="page-blurb-title">
<?= $heading ?>
<div class="underline-green-strong underline-130"></div>
</div>
<div class="page-blurb-parag blurb-70">
<?= $parag ?>
</div>
</div>
<?php if($subservices->have_posts()): ?>
<div class="sub-services-container">
<?php while($subservices->have_posts()): $subservices->the_post(); ?>
<?php
$postID = get_the_id();
$servicepage = get_post_meta($postID, 'service_page', true);
?>
<div class="sub-service">
<?php if(has_post_thumbnail()): ?>
<div class="sub-service-icon" title="Icons by Freepik from flaticon.com"><?php the_post_thumbnail(); ?></div>
<?php endif; ?>
<p class="service-description"><?php the_title() ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php get_footer(); ?>