Love丶FFC's Blog

WordPress搭建自己的网站系统_6:编写一个简易的文章页(上)

2019-10-28 10:06:29
阅读:844   •   评论:14
标签:

这篇文章主要讲解编写一个文章页之前要做的准备工作。

在上一篇文章我们已经发布了一篇文章,因此我们只需再编写一个single.php文件即可,WordPress默认将single.php设置为文章的内容页,如果开发者不编写single.php的话,点击文章的链接就无法查看具体内容。

1.首先在EditPlus中新建一个single.php文件。

2.开始正式编写single.php中的代码,代码如下:

  1. <?php get_header(); ?>
  2. <div class="Public-Position">
  3. <div>位置:<a href="http://10.100.124.68/initial/">首页</a>-><a href="#"><?php echo the_title(); ?></a></div>
  4. </div>
  5. <div class="Public-Article">
  6. <h1 class="Public-Article-Title"><?php echo $post->post_title;?></h1>
  7. <div class="Public-Article-Information">
  8. <b><?php echo $post->post_date;?></b>
  9. </div>
  10. <div class="Public-Article-Content"><?php echo $post->post_content;?>
  11. </div>
  12. </div>
  13. <?php get_footer(); ?>

看一下浏览效果。

此时还没有编写针对single.php的CSS文件,同时也没有编写header.php和footer.php,因此目前要先编写两个公共模板。

3.新建header.php文件,将index.php中26行以前的代码都剪切粘贴到header.php中。同时在index.php中添加<?php get_header(); ?>。

4.新建footer.php文件,将index.php中28行以后的代码都剪切粘贴到footer.php中。 同时在index.php的底部添加<?php get_footer()? > 。

此时刷新一下页面,会看到显示效果改变,因为single.php将公共头部和公共底部都引入了。

下一篇文章开始讲解文章页的相关调用数据的代码,同时编写一段CSS。

评论板

共有 14 条评论

  1. fruinly

    38 In a driving study by Betts and colleagues 55 subjects taking 5 mg of prochlorperazine 3 times daily showed increased carelessness and significant slowing on a maneuvering task cialis from usa pharmacy 1 cre ERT2 Luo J and Lox tdTomato B6

  2. jordans for cheap

    I just wanted to thank you for the fast service. and they look great. I received them a day earlier than expected. like the I will definitely continue to buy from this site. either way I will recommend this site to my friends. Thanks!
    jordans for cheap https://www.cheaprealjordan.com/

  3. cheap real jordans

    I just wanted to thank you for the fast service. or possibly a they look great. I received them a day earlier than expected. significantly I will definitely continue to buy from this site. manner in which I will recommend this site to my friends. Thanks!
    cheap real jordans https://www.realcheapretrojordanshoes.com/

  4. original louis vuittons outlet

    I just wanted to thank you for the fast service. or just they look great. I received them a day earlier than expected. the same as I will definitely continue to buy from this site. an invaluable I will recommend this site to my friends. Thanks!
    original louis vuittons outlet https://www.cheapreallouisvuitton.com/

  5. cheap louis vuitton outlet

    I just wanted to thank you for the fast service. and they look great. I received them a day earlier than expected. such I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
    cheap louis vuitton outlet https://www.bestlouisvuittonoutlet.com/

  6. cheap jordans for sale

    I just wanted to thank you for the fast service. aka they look great. I received them a day earlier than expected. similar to I will definitely continue to buy from this site. regardless I will recommend this site to my friends. Thanks!
    cheap jordans for sale https://www.realjordansretro.com/

  7. engarma

    priligy dapoxetine amazon Johnathon josPhyeaWcgDtM 5 29 2022

  8. louis vuitton outlet

    Read reviews and was a little hesitant since I had already inputted my order. or maybe a but thank god, I had no issues. just like the received item in a timely matter, they are in new condition. direction so happy I made the purchase. Will be definitely be purchasing again.
    louis vuitton outlet https://www.louisvuittonsoutletstore.com/

  9. authentic cheap jordans

    Read reviews and was a little hesitant since I had already inputted my order. or else but thank god, I had no issues. particularly the received item in a timely matter, they are in new condition. direction so happy I made the purchase. Will be definitely be purchasing again.
    authentic cheap jordans https://www.retrocheapjordansshoes.com/

  10. cheap real jordans

    Read reviews and was a little hesitant since I had already inputted my order. or possibly but thank god, I had no issues. which includes received item in a timely matter, they are in new condition. an invaluable so happy I made the purchase. Will be definitely be purchasing again.
    cheap real jordans https://www.realjordansshoes.com/

  11. cheap louis vuitton

    Read reviews and was a little hesitant since I had already inputted my order. or even a but thank god, I had no issues. just like received item in a timely matter, they are in new condition. you decide so happy I made the purchase. Will be definitely be purchasing again.
    cheap louis vuitton https://www.louisvuittonsoutletonline.com/

  12. Preliaf

    Demarcus, USA 2022 06 26 09 30 58 priligy generico

  13. Preliaf

    Today I had TONS of ewcm on day 7 of my cycle, and it is not my ovulation time dog viagra

  14. qHDHOJZO

    can i buy cialis online albuterol and cisapride both increase QTc interval

--------查看该分类下最新文章--------
^
新版博客正在完善中!域名:http://www.loveffc:8080,点击跳转,完全移植后将去除端口号。

Copyright © 2018 - 2021 FFC的小站 - 滇 ICP 备 18010780 号 - 1

- Powered by WordPress & AliYun · Theme by FFC -

- Environment by Windows & XAMPP · Designed by WebStorm & VSCode -

已运行:

访问量:451744