怎么用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()) : ?>
&nbsp;   <?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() 的外面,只需要分号去结束或者关闭。
登录后复制


以上就是怎么用wordPress做模板的详细内容,更多请关注慧达AI工具网其它相关文章!

转载请说明出处 内容投诉内容投诉
慧达seo-站长工具-seo工具-采集-发布-AI文章生成发布工具 » 怎么用wordpress做模板

慧达AI专注站群seo管理工具

查看演示 官网购买