1+ <?php
2+ /**
3+ * Custom Post Type ('portfolio') - Single Template
4+ * @package WordPress
5+ * @subpackage Project_Zero
6+ * @since 0.1
7+ *
8+ * This template applies to all pages without a specialised page template or a custom page template.
9+ * To create a specialised page template, save this as page-{slug}.php or page-{id}.php, as required.
10+ *
11+ * For more information, check out
12+ * @link https://developer.wordpress.org/themes/template-files-section/page-template-files/
13+ */
14+
15+ get_header ();
16+ if ( have_posts () ) : while ( have_posts () ) : the_post ();
17+ ?>
18+ <section id="project-title" class="project-title page-title single-title">
19+ <div class="container">
20+ <h1 class="title"><?php the_title (); ?> </h1>
21+ </div> <!-- .container -->
22+ </section> <!-- #project-title -->
23+
24+ <section id="project-<?php the_ID (); ?> " class="single-project page-container">
25+
26+ <div class="container row">
27+
28+ <main id="page-content" <?php post_class ( array ('col-8 ' ) ); // Lists all classes for the post, and adds the 'col-8' CSS class ?> >
29+
30+ <?php if ( has_post_thumbnail () ) {
31+ /**
32+ * @var $featured - Returns attachment source as an array, based on an ID number.
33+ * get_post_thumbnail_id( get_the_ID() ) gets the ID of the featured image linked to the post ID.
34+ * $featured[0] - Image URL
35+ * $featured[1] - Image width in pixels
36+ * $featured[2] - Image height in pixels
37+ */
38+ $ featured = wp_get_attachment_image_src ( get_post_thumbnail_id ( get_the_ID () ), 'full ' );
39+ ?>
40+ <figure class="featured-image">
41+ <img src="<?php echo $ featured [0 ]; ?> " width="<?php echo $ featured [1 ]; ?> " height="<?php echo $ featured [2 ]; ?> " />
42+ </figure> <!-- .featured-content -->
43+ <?php } ?>
44+
45+ <article class="project-content">
46+ <div class="entry">
47+ <?php the_content (); ?>
48+ </div> <!-- .entry -->
49+ </article> <!-- .project-content -->
50+
51+ </main> <!-- #page-content -->
52+
53+ <aside id="project-sidebar" class="col-4">
54+ <?php if ( !empty ( get_post_meta ( get_the_ID (), 'client_name ' , true ) ) ){ ?>
55+ <!-- Client information -->
56+ <h6 class="project-meta meta-title client">Client:</h6>
57+ <p class="project-meta meta-data client"><?php echo get_post_meta ( get_the_ID (), 'client_name ' , true ); ?> </p>
58+ <?php } ?>
59+
60+ <?php if ( !empty ( get_post_meta ( get_the_ID (), 'client_url ' , true ) ) ){ ?>
61+ <!-- Website link -->
62+ <h6 class="project-meta meta-title website">Website:</h6>
63+ <p class="project-meta meta-data website"><a href="<?php echo get_post_meta ( get_the_ID (), 'client_url ' , true ); ?> "
64+ target="<?php echo get_post_meta ( get_the_ID (), 'is_external ' , true ); ?> "
65+ rel="<?php if ( get_post_meta ( get_the_ID (), 'nofollow ' , true ) === '1 ' ){
66+ echo 'nofollow, ' ;
67+ }
68+ if ( get_post_meta ( get_the_ID (), 'noindex ' , true ) === '1 ' ) {
69+ echo 'noindex ' ;
70+ } ?> "><?php echo get_post_meta ( get_the_ID (), 'client_url ' , true ); ?> </a></p>
71+ <?php } ?>
72+
73+ <!-- Services custom taxonomy -->
74+ <h6 class="project-meta meta-title services">Services:</h6>
75+ <p class="project-meta meta-data services">
76+ <?php
77+ $ services_arr = get_the_terms ( get_the_ID (), 'project_services ' );
78+ $ services = join (', ' , wp_list_pluck ($ services_arr , 'name ' ));
79+ echo $ services ;
80+ ?>
81+ </p>
82+ </aside> <!-- #project-sidebar -->
83+
84+ </div>
85+
86+ </section> <!-- #project-{page_id} -->
87+ <?php
88+ endwhile ; endif ;
89+ get_footer ();
90+ ?>
0 commit comments