未分類

2016-11-20の作業のまとめ【2】|テンプレートタウン通信【1】=template-01.php】|テンプレートタウン通信【2】=template-02.php 2016年11月21日

2016-11-20の作業のまとめ【2】|テンプレートタウン通信【1】=template-01.php】|テンプレートタウン通信【2】=template-02.php

2016-11-20の作業のまとめ【2】テンプレートタウン通信【1】分

WORDPRESS テーマのディレクトリに、投稿用の追加テンプレートを設置。
single.phpの変更のテンプレ。
ソースは下記。
template-01.php ←これは今から書き換える。

<?php
/*
Single Post Template: template-01
*/
?>
<?php 
/*
* single post template
*/
get_header(); 
?>
<?php get_header(); ?>

<?php get_template_part( 'template-part', 'head' ); ?>

<?php get_template_part( 'template-part', 'topnav' ); ?>

<!-- start content container -->
<?php
if ( function_exists( 'connect_breadcrumb' ) && get_theme_mod( 'breadcrumbs-check', 1 ) != 0 ) {
	connect_breadcrumb();
}
?> 
<!-- start content container -->
<div class="row rsrc-content">   
	<?php get_sidebar( 'left' ); ?>    
	<article class="col-md-<?php connect_main_content_width(); ?> rsrc-main">
		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                         
				<div <?php post_class( 'rsrc-post-content' ); ?>>
					<header>                              
						<div class="time-info" >
							<div class="thetime"><?php the_time( 'j' ); ?></div>
							<div class="thedate"><?php the_time( 'M' ); ?></div>

						</div>
						<h1 class="entry-title page-header">
							<?php the_title(); ?>
						</h1>                              
                          
					</header>
                                          
					<div class="entry-content">
						<?php the_content(); ?>
					</div>                          
					<?php wp_link_pages(); ?>
					<div class="cat-list">
						<?php the_category( ' ' ); ?>
					</div>  

					<?php if ( get_theme_mod( 'post-nav-check', 1 ) == 1 ) : ?>                            
						<div class="post-navigation row">
							<div class="post-previous col-xs-6"><?php previous_post_link( '%link', '<span class="meta-nav">' . __( 'Previous:', 'connect' ) . '</span> %title' ); ?></div>
							<div class="post-next col-xs-6"><?php next_post_link( '%link', '<span class="meta-nav">' . __( 'Next:', 'connect' ) . '</span> %title' ); ?></div>
						</div>                            
					<?php endif; ?>                            
					<?php if ( get_theme_mod( 'related-posts-check', 1 ) == 1 ) : ?>
						<?php get_template_part( 'template-part', 'related' ); ?>
					<?php endif; ?>
                            
                       
				</div>        
			<?php endwhile; ?>        
		<?php else : ?>            
			<?php get_404_template(); ?>        
		<?php endif; ?>    
	</article>        
	<?php get_sidebar( 'right' ); ?>
</div>
<!-- end content container -->

<!-- end content container -->

<?php get_footer(); ?>

template-02.php

<?php
/*
Single Post Template: タウン通信【2】
*/
?>
<?php 
/*
* single post template
*/
get_header(); 
?>
<?php get_header(); ?>

<?php get_template_part( 'template-part', 'head' ); ?>

<?php get_template_part( 'template-part', 'topnav' ); ?>      
<!-- start content container -->
<?php
if ( function_exists( 'connect_breadcrumb' ) && get_theme_mod( 'breadcrumbs-check', 1 ) != 0 ) {
	connect_breadcrumb();
}
?> 
<!-- start content container -->
<div class="row rsrc-content">   
	<?php get_sidebar( 'left' ); ?>    
	<article class="col-md-<?php connect_main_content_width(); ?> rsrc-main">
		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                         
				<div <?php post_class( 'rsrc-post-content' ); ?>>
					<header>                              
						<div class="time-info" >
							<div class="thetime"><?php the_time( 'j' ); ?></div>
							<div class="thedate"><?php the_time( 'M' ); ?></div>

						</div>
						<h1 class="entry-title page-header">
							<?php the_title(); ?>
						</h1>                              
                          
					</header>
<table class="type02">
<?php if ( get_post_meta($post->ID,'eventname',TRUE) ): ?>
	<tr>
		<th scope="row">【伝言タイトル】</th>
		<td><?php echo post_custom("eventname")?></td>
	</tr>
<?php endif;?> 
<?php if ( get_post_meta($post->ID,'party',TRUE) ): ?>
	<tr>
		<th scope="row">【主催団体名】</th>
		<td><?php echo post_custom("party")?></td>
	</tr>
<?php endif;?> 
<?php if ( get_post_meta($post->ID,'event_detail',TRUE) ): ?>
	<tr>
		<th scope="row">【イベント内容】</th>
		<td><?php echo post_custom("event_detail")?></td>
	</tr>
<?php endif;?>
<?php if ( get_post_meta($post->ID,'place',TRUE) ): ?>
	<tr>
		<th scope="row">【会場】</th>
		<td><?php echo post_custom("place")?></td>
	</tr>
<?php endif;?>
<?php if ( get_post_meta($post->ID,'Map_iframe',TRUE) ): ?>
	<tr>
		<th scope="row">【会場地図】</th>
		<td><?php echo post_custom("Map_iframe")?></td>
	</tr>
<?php endif;?>
<?php if ( get_post_meta($post->ID,'event_day',TRUE) ): ?>
	<tr>
		<th scope="row">【開催日】</th>
		<td><?php echo post_custom("event_day")?></td>
	</tr>
<?php endif;?>
<?php if ( get_post_meta($post->ID,'event_time',TRUE) ): ?>
	<tr>
		<th scope="row">【開催時間】</th>
		<td><?php echo post_custom("event_time")?></td>
	</tr>
<?php endif;?>
<?php if ( get_post_meta($post->ID,'time_note',TRUE) ): ?>
	<tr>
		<th scope="row">【備考】</th>
		<td><?php echo post_custom("time_note")?></td>
	</tr>
<?php endif;?> 
<?php if ( get_post_meta($post->ID,'askfor',TRUE) ): ?>
	<tr>
		<th scope="row">【問い合わせ先】</th>
		<td><?php echo post_custom("askfor")?></td>
	</tr>
<?php endif;?> 
<?php if ( get_post_meta($post->ID,'notice_url',TRUE) ): ?>
	<tr>
		<th scope="row"><a href="<?php echo post_custom("notice_url")?>" target="_blank">【関連ホームページ】</a></th>
		<td><a href="<?php echo post_custom("notice_url")?>" target="_blank"><?php echo post_custom("notice_url")?></a></td>
	</tr>
<?php endif;?> 
<?php if ( get_post_meta($post->ID,'studio_rec',TRUE) ): ?>
	<tr>
		<th scope="row">【スタジオ収録】</th>
		<td><?php echo post_custom("studio_rec")?></td>
	</tr>
<?php endif;?> 
</table>     
                                          
					<div class="entry-content">
						<?php the_content(); ?>
					</div>                          
					<?php wp_link_pages(); ?>
					<div class="cat-list">
						<?php the_category( ' ' ); ?>
					</div>  

					<?php if ( get_theme_mod( 'post-nav-check', 1 ) == 1 ) : ?>                            
						<div class="post-navigation row">
							<div class="post-previous col-xs-6"><?php previous_post_link( '%link', '<span class="meta-nav">' . __( 'Previous:', 'connect' ) . '</span> %title' ); ?></div>
							<div class="post-next col-xs-6"><?php next_post_link( '%link', '<span class="meta-nav">' . __( 'Next:', 'connect' ) . '</span> %title' ); ?></div>
						</div>                            
					<?php endif; ?>                            
					<?php if ( get_theme_mod( 'related-posts-check', 1 ) == 1 ) : ?>
						<?php get_template_part( 'template-part', 'related' ); ?>
					<?php endif; ?>
                            
                       
				</div>        
			<?php endwhile; ?>        
		<?php else : ?>            
			<?php get_404_template(); ?>        
		<?php endif; ?>    
	</article>        
	<?php get_sidebar( 'right' ); ?>
   
<!-- end content container -->


<?php get_footer(); ?>