Wordpress——一些内部参数记录

bloginfo(’stylesheet_url’)  调用 style.css 文件所在的路径

bloginfo(’name’)   调用wordpress的系统名字

bloginfo(‘url’) 调用wordpress的地址,例如:http://localhost/wordpress

bloginfo(’description’)  调用博客信息,这里的是描述

posts_nav_link() 日志导航链接,显示效果为:Next Page >>,

 posts_nav_link(’in between’,”before’,”after’); 这个为定制的导航链接

the_ID() 日志的id,必须用于循环列表中

wp_list_cats();  调用分类链接列表

wp_list_cats(’sort_column=name&optioncount=1&hierarchical=0′);//sort_column=name – 把分类按字符顺序排列,optioncount=1 – 显示每个分类含有的日志数,hierarchial=0 – 不按照层式结构显示子分类,子分类链接是列在列表中第一级,& – 每次增加另一个参数的时候,需在它之前要输入 & 用来把和现有的参数区分开

wp_list_pages() 导航菜单列表

wp_list_pages('depth=1&sort_column=menu_order&title_li=' );depth表示菜单分一级显示

wp_get_archives(’type=monthly’);增加存档类表,这里是一月来表示 

get_links_list();这个是友情链接列表 

get_calendar(); 在wordpress中添加一个日历

 wp_register();注册

 wp_loginout();登陆/登出

在wordpress中添加一个搜索:

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
  <div>
  
<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="15" /><br />
  
<input type="submit" id="searchsubmit" value="Search" />
  </div>
</form>

 

下面这段代码是首页新闻列表的循环:

<?php if(have_posts()) : ?>//这一段是检查是否有日志

<?php while(have_posts()) : the_post(); ?>//这段是通过循环将每一篇日志显示出来

  
<h2 class="title">//这个标签里面的都是title

    
<a href="<?php the_permalink() ?>" //这里是日志标题的链接地址
    rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">//这里php标签里面的是标题

    
<?php the_title(); ?>//这里也是标题

    
</a>

  
</h2>
  
<div class="postdate">
<img src="<?php bloginfo('template_url'); ?>/images/date.png" /> //时间的图标
     <?php the_time('F jS, Y') ?>//时间
<img src="<?php bloginfo('template_url'); ?>/images/user.png" />
<?php the_author() ?> //作者
<?php if (current_user_can('edit_post', $post->ID)) //用户是否能够编辑,也就是是否是发布者
{ ?>
  
<img src="<?php bloginfo('template_url'); ?>/images/edit.png" />//编辑图标
  <?php edit_post_link('Edit', '', ''); //编辑链接
} ?>
 
</div>
  
<div class="entry">    
    
<?php the_content('Read more...'); ?>//显示摘要内容,这里显示的为在文章中插入“more"标签之前的文字(more标签在编辑器里)
  </div>

<?php endwhile; ?>//结束循环

<?php endif; ?>

  这里是上面一段代码的显示内容的例子:

大家有什么不懂的可以在下面留言~~~


  



原文地址:https://www.cnblogs.com/bugY/p/2147410.html