wordpress主题制作index.php基本框架代码

如果自己学着制作wordpress主题,那么index.php文件的制作必须掌握,我们在这个文件必须引入头部文件,边栏,底部等等,提供的模板没有更多的html布局,只是框架必须的一些功能,你如果是个初学者,可以试着注释修改自己的index.php文件。

更多的主题制作教程,建议你看看 利用Bootstrap构建你的响应式WordPress主题(一)

  1. //引入头部文件
  2. <?php get_header();?>
  3. <div id="main">	
  4. //循环开始
  5. <?php if (have_posts()) : ?>
  6. <?php while (have_posts()) : the_post(); ?>
  7.  
  8. 标题:<a href="<?php the_permalink() ?>"><?php the_title_attribute(); ?></a>
  9.  
  10. //调用文章内容:
  11. <?php the_content("Read More..."); ?>
  12. //调用文章内容摘要:
  13. <?php the_excerpt("Read More..."); ?>
  14.  
  15. 作者:<?php the_author_posts_link(); ?>
  16. 日期:<?php the_time('F d, Y') ?>
  17.       <?php the_time('m-d') ?>//时间格式
  18.  
  19. 评论调用:<?php comments_number('No Comment', '1 Comment', '% Comments' );?>
  20. 文章所属分类:标签:<?php the_category(', ') ?>
  21. //上一页,下一页调用:
  22. <?php endwhile; ?>
  23. <?php else : ?>
  24. <?php endif; ?>
  25. <div style="float:left"><?php previous_post_link('&laquo; %link'); ?></div>
  26. <div style="float:right"><?php next_post_link('%link &raquo;'); ?></div>
  27. </div>	<!-- man ends here -->	
  28.  
  29. //引入边栏
  30. <?php get_sidebar();?>
  31. //引入底部
  32. <?php get_footer();?>

代码不能复制后直接就运行,要根据自己的主题特征适当的添加和删除,特别是静态的html布局代码,自己完成设计和添加!

分享到:

用微信扫一扫,分享给朋友


发布日期:

所属分类: WordPress、WordPress 主题