Skip to content

Commit

Permalink
single project template
Browse files Browse the repository at this point in the history
  • Loading branch information
braginteractive committed Nov 7, 2017
1 parent c0c6033 commit 9577d39
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 1 deletion.
24 changes: 23 additions & 1 deletion inc/metaboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,30 @@ function cmb2_stanleywp_metaboxes() {
'type' => 'textarea',
) );


/**
* metabox for project
*/
$cmb_project = new_cmb2_box( array(
'id' => 'project_metabox',
'title' => __( 'Images', 'stanleywp' ),
'object_types' => array( 'project', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
// 'cmb_styles' => false, // false to disable the CMB stylesheet
// 'closed' => true, // Keep the metabox closed by default
) );

// Images for project
$cmb_project->add_field( array(
'name' => __( 'Images', 'stanleywp' ),
'desc' => __( 'Upload images', 'stanleywp' ),
'id' => $prefix . 'images',
'type' => 'file_list',
) );



// Add other metaboxes as needed

}
41 changes: 41 additions & 0 deletions single-project.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package StanleyWP
*/

get_header(); ?>


<div id="primary" class="content-area-full">
<main id="main" class="site-main" role="main">

<?php
while ( have_posts() ) : the_post();

get_template_part( 'template-parts/content', 'project' ); ?>

<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<?php //the_post_navigation();

// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif; ?>

</div><!-- .col-md-8 -->
</div><!-- .row -->
</div><!-- .container -->

<?php endwhile; // End of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->

<?php
get_footer();
67 changes: 67 additions & 0 deletions template-parts/content-project.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Template part for displaying posts
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package StanleyWP
*/

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<div class="container">
<div class="row justify-content-center text-center">
<div class="col-md-6">

<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->

<div class="entry-content">
<?php
the_content( sprintf(
/* translators: %s: Name of current post. */
wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'stanleywp' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '<span class="screen-reader-text">"', '"</span>', false )
) );

wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'stanleywp' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->

</div><!-- .col-md-6 -->
</div><!-- .row -->


<div class="row justify-content-center">
<div class="col-md-8">

<?php
// Get the list of files
$files = get_post_meta( get_the_ID(), '_stanleywp_images', 1 );

// Loop through them and output an image
foreach ( (array) $files as $attachment_id => $attachment_url ) {
echo '<div class="mb-4">';
echo wp_get_attachment_image( $attachment_id, 'full' );
echo '</div>';
}
?>

</div><!-- .col-md-8 -->
</div><!-- .row -->


<footer class="entry-footer">
<?php stanleywp_entry_footer(); ?>
</footer><!-- .entry-footer -->


</div><!-- .container -->

</article><!-- #post-## -->

0 comments on commit 9577d39

Please sign in to comment.