怎么用wordpress做模板

怎么用wordpress做模板

下面來教大家做一個簡易的wordpress模板(不含style樣式的編寫),主要是一些相關函數的調用

推薦教程:WordPress教程

1、wordpress模板制作之標題調用

<title> <?php  bloginfo(&#39;name&#39;); ?><?php  wp_title(); ?> </title> //格式是:網站名》文章名,比如:卓創威視》無線門鈴zc-08 <title> <?php  the_title(); ?>_<?php  bloginfo(&#39;name&#39;); ?> </title> //格式是:文章名_網站名,比如:無線門鈴zc-08_卓創威視 <a>"&gt;<?php  bloginfo(&#39;name&#39;); ?></a> //標題加鏈接

  第一種默認在標題前加一個》箭頭號,可以用在首頁調用;而純粹是調用文章標題,可以用在文章和列表頁

2、wordpress模板制作之列表調用

<?php  if(have_posts()) : ?> ????<?php  while(have_posts()) : the_post(); ?> ????//if(have_posts())?–?檢查博客是否有日志。while(have_posts())?–?如果有日志,那么當博客有日志的時候,執行下面?the_post()?這個函數。the_post()?–?調用具體的日志來顯示。 ????????<h2><a>"?title="<?php  the_title(); ?>"&gt;<?php  the_title(); ?></a></h2> ????????//調用標題,帶鏈接 ????????<?php  the_excerpt(); ?> ????????//或者用這個調用文章摘要 ????<?php  endwhile; ?> ????????<?php  posts_nav_link(); ?> ????????//分頁導航 <?php  else : ?>???????????? ????沒有文章??? <?php  endif; ?> //注釋:并不是所有的代碼都需要兩部分用來打開和關閉。有些代碼能夠自我關閉,這就解釋了?have_posts()?和?the_post();?這兩個函數。因為?the_post();?在?if()?和?while()?的外面,只需要分號去結束或者關閉。

3、wordpress模板制作之文章頁調用

<?php  if(have_posts()) : ?> ????<?php  while(have_posts()) : the_post(); ?> ????//if(have_posts())?–?檢查博客是否有日志。while(have_posts())?–?如果有日志,那么當博客有日志的時候,執行下面?the_post()?這個函數。the_post()?–?調用具體的日志來顯示。 ????????<h1><a>"?title="<?php  the_title(); ?>"&gt;<?php  the_title(); ?></a></h1> ????????//調用標題,帶鏈接 ????????<?php  the_content(); ?> ????????//調用文章全部內容 ????<?php  endwhile; ?> ????????<?php  previous_post_link(&#39;%link&#39;) ?>?<?php  next_post_link(&#39;%link&#39;) ?> ????????//上一頁、下一頁導航 <?php  else : ?>???????????? ????沒有文章 <?php  endif; ?> //注釋:并不是所有的代碼都需要兩部分用來打開和關閉。有些代碼能夠自我關閉,這就解釋了?have_posts()?和?the_post();?這兩個函數。因為?the_post();?在?if()?和?while()?的外面,只需要分號去結束或者關閉。

以上就是怎么用

? 版權聲明
THE END
喜歡就支持一下吧
點贊12 分享