Heim  >  Artikel  >  CMS-Tutorial  >  So verwenden Sie WordPress als Vorlage

So verwenden Sie WordPress als Vorlage

angryTom
angryTomOriginal
2019-07-19 09:12:592897Durchsuche

So verwenden Sie WordPress als Vorlage

Im Folgenden erfahren Sie, wie Sie eine einfache WordPress-Vorlage (ohne Stylewriting) erstellen und dabei hauptsächlich einige verwandte Funktionen aufrufen.

Empfohlene Tutorials: WordPress-Tutorial

1. Titelaufruf für WordPress-Vorlagenproduktion

<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 href="<?php bloginfo(&#39;url&#39;); ?>"><?php bloginfo(&#39;name&#39;); ?></a>
//标题加链接

Der erste Typ

2. Listenaufruf in der WordPress-Vorlagenproduktion

<?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
    //if(have_posts()) – 检查博客是否有日志。while(have_posts()) – 如果有日志,那么当博客有日志的时候,执行下面 the_post() 这个函数。the_post() – 调用具体的日志来显示。
        <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?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. Artikelseitenaufruf für WordPress-Vorlagenproduktion

<?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
    //if(have_posts()) – 检查博客是否有日志。while(have_posts()) – 如果有日志,那么当博客有日志的时候,执行下面 the_post() 这个函数。the_post() – 调用具体的日志来显示。
        <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?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() 的外面,只需要分号去结束或者关闭。


Das obige ist der detaillierte Inhalt vonSo verwenden Sie WordPress als Vorlage. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn