mythemeを作成していく際には、indexをまず作成し、それをheader, sidebar, footer, functions, style.cssなどにファイル分割していきます。wp_header、wp_footer、ウェジェットなど独自のルールが幾つかありますが、調べながら進めるとよいでしょう。
ショートコードなども簡単に作成できます。
<?php get_header(); ?>
<div id="main" class="container">
<div id="posts">
<?php
if (have_posts()):
while(have_posts()):
the_post();
?>
<div class="post">
<div class="post-header">
<h2>
<a href="<?php echo the_permalink(); ?>"><php the_title(); ?></a>
</2>
<div class="post-meta">
<?php echo get_the_date(); ?>【<?php the_category(', '); ?>】
</div>
</div>
<div class="post-content">
<div class="post-image">
<?php if (has_post_thumbnail()): ?>
<?php the_post_thumbnail(array(100, 100)); ?>
<?php else: ?>
<img src="<?php echo get_template_directory_uri();?>img/noimage.png" width="100" height="100">
<?php endif; ?>
</div>
<div class="post-body">
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</div>
<?php endwhile;
else:
?>
<p>記事はありません! </p>
<?php
endif;
?>
<div class="navigation">
<div class="prev"><?php previous_posts_link(); ?></div>
<div class="next"><?php next_posts_link(); ?></div>
</div>
</div><!-- /posts -->
<?php get_sidebar(); ?>
</div><!-- /main -->
<?php get_footer(); ?>
<?php
add_theme_support('menus');
register_sidebar(
array(
'before_widget' => '<div class="widget">',
'after_widget' => '<div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
add_theme_support('post_thumbnails');
function shortcode_tw(){
return '<a href="http://twitter.com/hogehoge">@hogehoge</a>をフォローしてね'
}
add_shortcode('tw','shortcode_tw');