Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用文章相关 API #18

Open
deepthan opened this issue Jan 28, 2018 · 0 comments
Open

调用文章相关 API #18

deepthan opened this issue Jan 28, 2018 · 0 comments

Comments

@deepthan
Copy link
Owner

3. 调用文章


  <div class="post" id="post<?php the_ID(); ?>">

    <?php if(have_posts()): ?> 
        <?php while(have_posts()) : the_post(); ?>

           <h2>                                      // ' title= '  鼠标移上去显示的内容
                <a href="<?php the_permalink(); ?>"  title="<?php the_title(); ?>" >      -> 标题
                   <?php the_title(); ?>
                </a>
           </h2>

           <p>
                <?php the_content(); ?>                   -> 内容

                <div class="postmetadata">                -> 发表时间等
                    <?php the_category() ?>
                    <?php the_author(); ?>
                    <?php the_date(); ?>
                </div>
           </p>

        <?php endwhile; ?>

        <?php else: ?>
        <div>
            <p><?php  _e('Not Found'); ?></p>
        </div>
    <?php endif; ?>
  </div>

  • if(have_posts()): 检查是否有日志,那么当有日志的时候,执行下面 the_post()这个函数
  • while(have_posts()): 当博客有日志的时候,执行下面 the_post()这个函数
  • the_post(): 调用具体的日志来显示
  • endwhile: 关闭while()
  • endif: 关闭if
  • the_permalink(): 调用每篇日志地址的PHP函数
  • the_title(): 调用日志标题的函数
  • the_content(): 调用日志内容的函数
  • the_category(): 日志类别
  • the_author(): 日志作者
  • the_date(): 日志发布时间
  • the_ID(): 给每篇日志都添加一个id,给它进行样式添加。
    &&&& 主循环: the loop &&&&
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant