wordpress練習



<?php get_header(); ?>
<!-- コンテンツ -->

<div id="content">

<?php if( is_category()): ?>
<p id="pagetitle"><?php single_cat_title(); ?></p>
<?php endif; ?>

<?php if(is_month()): ?>
<p id="pagetitle"><?php single_month_title(); ?></p>
<?php endif; ?>

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

<div class="post">
<h2><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></h2>

<?php the_content();?>
<p class="postinfo">
<?php echo get_the_date();  ?>
<?php the_time();?>
|
カテゴリー:<?php the_category(','); ?>
|
<a href="<?php comments_link(); ?>">コメント
<?php comments_number('(0)','(1)','(%)'); ?></a>
</p>
</div>

<?php if(is_single()) :?>
<p class="pagelink">
<span class="oldpage"><?php previous_post_link(); ?></span>
<span class="newpage"><?php next_post_link();  ?></span>
</p>
<?php endif; ?>
<?php endwhile; endif; ?>

<?php if(is_home()): ?>
<p class="pagelink">
<span class="oldpage"><?php next_posts_link('&laquo; 古い記事'); ?></span>
<span class="newpage"><?php previous_posts_link('新しい記事 &raquo;'); ?></span>
</p>
<?php endif; ?>

<?php if(is_archive()): ?>
<p class="pagelink">
<span class="oldpage"><?php next_posts_link('&laquo; 古い記事'); ?></span>

<span class="newpage"><?php previous_posts_link(' 新しい記事 &raquo;'); ?></span>
</p>
<?php endif; ?>

<?php comments_template(); ?>

</div>

<!--サイドバー-->

<div id="sidebar">
<ul>
<?php dynamic_sidebar(); ?>
</ul>

<p class="feed">
<img src="<?php bloginfo('template_url'); ?>/feed-icon-28x28.png" alt="*" width="28" height="28" />
<a href="<?php bloginfo('rss2_url') ;?>">
</a>
RSS FEED
</p>
</div>

<?php get_footer(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type');?>;charset=<?php bloginfo('charset');?>" />
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css"/>
<link rel="alternate" type="application/rss+xml" title="RSS フィード" href="<?php bloginfo('rss2_url'); ?>" />
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?> >
<!-- コンテナ-->
<div id="container">
<!-- ヘッダー-->

<div id="header">
<h1><a href="<?php  echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>
<p id="desc"><?php bloginfo('description'); ?></p>
<?php if(!(is_page('ビジネスサイト風のページ'))): ?>
<?php if(get_header_image()): ?>

<p id="image"><img src="<?php header_image(); ?>" alt="*"  width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" /></p>
<?php endif; ?>
<?php endif; ?>
</div>

<!-- ナビゲーションバー -->

<div id="nav">

<?php wp_nav_menu(array('theme_location'=>'navigation' )); ?>

</div>
  • functions.php
<?php
register_sidebar();


//受信したコメント

function mydesign($comment, $args,$depth){
	$GLOBALS['comment'] = $comment; ?>

<li class="compost">
<?php comment_text(); ?>

<p class="cominfo">

<?php comment_date(); ?><?php comment_time(); ?>

|

<?php comment_author_link(); ?>

<?php 
}

//カスタムメニュー

register_nav_menus(array('navigation' =>'ナビゲーションバー'));

//カスタムヘッダー
add_custom_image_header(' ','admin_header_style');

function admin_header_style(){
?>

<style type="text/css">
#headimg {width: 760px!important}
</style>

<?php
}

define('NO_HEADER_TEXT',true);

define('HEADER_IMAGE','%s/default_header.jpg');

define('HEADER_IMAGE_WIDTH',760);

define('HEADER_IMAGE_HEIGHT',200);

//カスタム背景
add_custom_background();

add_filter( 'show_admin_bar', '__return_false' );

?>
<!--フッター-->

<div id="footer">
<address>Copyright &copy; <a href="mailto:<?php bloginfo('admin_email'); ?>">practice</a>,All rights reserved.</address>
</div>

</div>

</body>
</html>
<div id="comments">

<?php if(have_comments()):  ?>

<h3>コメント</h3>

<ul>

<?php wp_list_comments('callback=mydesign'); ?>

</ul>

<?php endif; ?>

<?php comment_form(); ?>

<p id="comfeed">

<?php post_comments_feed_link(); ?>

</p>

<?php if(pings_open()): ?>
<p id="trurl">
<strong>トラックバック URL : </strong>
<?php trackback_url(); ?>
</p>
<?php endif; ?>

</div>
<?php
/*Template Name: ビジネスサイト風テンプレート*/
 ?>
 <?php get_header(); ?>
 
 <!--コンテンツ-->
 
 <div id="topcontent">
 
 <?php if(have_posts()): while(have_posts()): the_post(); ?>
 
 <p><img src="<?php bloginfo('template_url' ); ?>/topimage.jpg" alt="*" width"760" height="370"/></p>
 
 <?php the_content(); ?>
 
 <?php endwhile; endif ;  ?>
 
 </div>
 
 <?php  get_footer(); ?>
/*
Theme Name: Sample Theme
Theme URI: http://www.www.www/
Description: This is my sample theme.
*/

/*コンテナ*/

div#container{
	width: 760px;
	margin: auto
}

/*ヘッダー*/

div#header h1 {
font-size: 1.875em;
margin: 0;
float: left;
margin-bottom: 4px
}

div#header h1 a {
	text-decoration: none;
	color: #000;
	}
	
div#header p#desc{
font-size: 0.75em;
color: #444;
margin: 0;
float: right;
margin-top: 18px;
}

div#header {
border-bottom: none;
padding-bottom: 0;
margin-bottom: 20px;	
}

div#header p#image{
	margin: 8px 0 0;
	}
	
/*ナビゲーションバー*/

div#nav {
	clear: both;
	width: 100%
}

div#header {
	margin-bottom: 0
	}
	
div#nav ul{
	background-color: #000;
	padding: 8px 0;
	margin: 0 0 20px
}

div#nav li a{
	font-size: 0.75em;
	color: #FFF;
	text-decoration: none;
}

div#nav li a:hover {
	color: #ffaa00;
}
	
div#nav li{
	display: inline;
	list-style-type: none;
	border-right: solid 1px #FFFFFF;
	padding-left: 15px;
	padding-right: 15px
}
	
/*コンテンツ*/
div#content {
	width: 515px;
	float: left;
}

p#pagetitle {
	font-size: 0.875em;
	font-weight: bold;
	color: #0c8bcd;
	border: dotted 1px #0c8bcd;
	text-align: center;
	padding: 10px 0;
	margin-top: 0
}

/*記事*/
div.post {
	border: solid 1px #0c8bcd;
	padding: 15px;
	margin-bottom: 20px;
	}
	
div.post h2{
	background-color:#a3d2f2;
	background-image: url(titlebar.png);
	font-size: 0.875em;
	padding: 10px;
	margin: 0;
}

div.post h2 a{
	text-decoration: none;
	color: #000
}

div.post p{
	font-size: 0.875em;
	line-height: 1.6;
	margin-top: 10px
	}
	
p.postinfo {
	color: #0c8bcd;
	text-align: right;
	margin: 20px 0 0;
	clear: both
}

p. postinfo a{
	color: #0c8bcd
	}
	
	/*記事内の画像*/
.aligncenter{
	display: block;
	margin-left: auto;
	margin-right: auto;
}
	
div.post img{
	border: none
}

.alignleft{
	float: left;
	margin-right: 10px;
	margin-bottom: 10px;
}

.alignright{
	float: right;
	margin-left: 10px;
	margin-bottom: 10px;
}

.wp-caption {
border: solid 1px #aaa;
text-align: center;
padding-top: 5px;
}
	
/*ページリンク*/

span.oldpage{
	float: left
}

span.newpage{
	float: right;
}

p.pagelink a{
fontsize: 0.75em;
color: #0c8bcd;
}

p.pagelink{
overflow: hidden;
width: 100%;
}

/* コメント */

#comments {
	border: solid 1px #0c8bcd;
	padding: 0 18px;
	margin: 20px 0
}

#comments h3{
	font-size: 0.875em;
	border-bottom: solid 1px #0c8bcd;
	padding-bottom: 3px;
	margin-top: 20px;
}

#comments p{
	font-size: 0.75em
}

#comments p a {
	color:#0c8bcd;
}

#comments input, #comments textarea {
	dispaly: block
}

#comments textarea{
	width: 450px;
}

#comments .required{
	color: #ff0000
}

#comments code{
	display: block;
	margin-top: 5px;
	font-size: smaller;
}

#comments ul{
	margin: 0;
	padding: 0;
}

#comments li.compost{
	list-style-type: none;
  border-bottom: dotted 1px #0c8bcd;
	margin-bottom: 20px;
}

#comments p.cominfo{
	text-align: right
}

#comments #comfeed a{
	background-image: url(feed-icon-12x12.png);
	background-repeat: no-repeat;
	background-position: 0 50%;
	padding-left: 17px;
	line-height: 1em;
	color: #000;
	text-decoration: none
}

#comments #comfeed{
	background-color: #a3d2f2;
	padding: 8px;
	margin-top: 30px
}

#comments #trurl {
	background-color: #a3d2f2;
	padding: 8px;
	margin-bottom: 30px;
}

/*サイドバー*/
div#sidebar{
	width: 220px;
	float: right;
}

div#sidebar ul{
	margin: 0;
	padding: 0;
}

div#sidebar li {
list-style-type: none
}

div#sidebar .widget{
	background-color: #0c8bcd;
	padding: 16px;
	margin-bottom: 10px;
}

div#sidebar h2{
font-size: 0.75em;
color: #fff;
border-bottom: solid 1px #fff;
padding-bottom: 8px;
margin: 0 0 10px
}

div#sidebar li li{
font-size: 0.75em;
margin-bottom: 4px;
background-image: url(listmark.gif);
background-repeat: no-repeat;
padding-left: 16px	
}

div#sidebar li li a{
text-decoration: none;
color: #fff	
}

/*カレンダー*/
.widget_calendar h2 {
	display: none
	}

#wp-calendar {
	font-size: 0.75em;
	color: #FFF;
	width: 100%
	}
	
#wp-calendar a{
	color: #FFF;
}

#wp-calendar td, #wp-calendar th{
	text-align: center;
}

#wp-calendar caption{
	font-weight: bold;
	text-align: left;
	border-bottom: solid 1px #FFFFFF;
	padding-bottom: 8px;
	margin-bottom: 8px;	
}

#wp-calendar #prev{
	text-align: left;
	padding-top: 3px;	
}

#wp-calendar #next{
	text-align: right;
	padding-top: 3px	
}

/* フィード */

p.feed {
	font-size: 0.75em;
	font-family: Verdana, Helvetica, sans-serif;
	border: solid 1px #0c8bcd;
	padding: 5px;
	margin: 25px 0
}

p.feed a{
	color:#444;
	text-decoration: none
}

p.feed img{
	vertical-align: middle;
	margin-right: 8px;
}

/*フッター*/
div#footer {
	clear: both;
	border-top: solid 3px #000;
	padding: 6px 0
}

address{
font-size: 0.75em;
font-style: normal;
font-family: Verdana, sans-serif;
margin: 0
}

address a{
color: #000	
	}
	
/* 固定ページ */
div#content.page{
	100%
}

/* トップページ */

div#topcontent p{
	text-align: center;
	font-size: 0.875em;
	line-height: 1.5;
	margin: 0 0 20px
}

/* コンテンツの背景 */

div.post,
p.feed,
#comments {
	background-color: #FFF}
<?php get_header(); ?>
<!-- コンテンツ -->

<div id="content">

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

<div class="post">
<h2><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></h2>

<?php the_content();?>

</div>

<p class="pagelink">
<span class="oldpage"><?php previous_post_link(); ?></span>
<span class="newpage"><?php next_post_link();  ?></span>
</p>
<?php endwhile; endif; ?>

<p class="pagelink">
<span class="oldpage"><?php next_posts_link('&laquo; 古い記事'); ?></span>
<span class="newpage"><?php previous_posts_link('新しい記事 &raquo;'); ?></span>
</p>

<p class="pagelink">
<span class="oldpage"><?php next_posts_link('&laquo; 古い記事'); ?></span>

<span class="newpage"><?php previous_posts_link(' 新しい記事 &raquo;'); ?></span>
</p>

</div>

<?php get_footer(); ?>