Author: Wayne

wordpress最重要全局函数$post

$post Contains data from the current post in The Loop. Properties ID(integer) The post ID. post_author(integer) The ID of the post author. post_date(string) The post date using the server’s current timezone. Format: yyyy-mm-dd hh:mm:ss Example: 2011-05-19 13:51:21 (default Unix format ‘F j, Y’) post_date_gmt(string) Same as above, but in GMT.post_content(string) The post content. post_title(string) The post’s […]

Comments教程

WordPress的comment form是以comments.php文件作为基础的,没有这个文件无法调取comment函数。 首先在目录下创建comments.php文件,然后在single.php里comment的位置上,用函数调取comments form的内容: comments_open( )来检查是否帖子开启了comments功能,每个帖子都可以在帖子编辑页面文档=》讨论区里设置是否单独启用comment. 接下来我们编辑comments.php的模板,首先在头部添加一段代码,来检测是否帖子设置了密码保护,如果是,就不显示comments的内容: 通过comment_form() 函数来调用评论时候的表格,wordpress也设置好了一切检验表格的机制,comment_form用法: 函数最主要有几个数组组成:‘comment_field’,‘must_log_in’,‘logged_in_as’, ‘title_reply’,‘title_reply_to’,‘label_submit’,‘submit_button’,‘submit_field’,‘field’等组成,field又由下级数组组成:‘author’,’email’,‘url’,‘cookies’等。comment_form里可以直接粘贴html,完整用法举例: WordPress把所有comments存储在$comments的变量中,要把他们全部都展现出来,可以通过foreach来遍历,循环和标签的用法如下: 同时要注意if条件的使用,设置如果没有开启comment或者comments数量为0时不展现comment form模板。 Comment的reply功能,我们会在下一篇教程中讲到。

wordpress几个路径函数

带uri类的路径函数展现结果都是链接形式的绝对定位,如”http://watchlist.cn/wp-content/themes/domains/assets/css/color-yellow.css”;不带uri的是相对应服务器文件夹的位置,如”D:\wwwroot\watchlist.cn/wp-content/themes/domains”;require,include之类需要调用电脑上文件位置的,用不带uri之类函数,需要调取css,js,jpg之类浏览器需要读取的文件,需要用到带uri的函数。 有些函数可用在子主题文件夹,有些则始终指向父级主题文件夹。 get_theme_file_uri( $file ); 路径是:http://watchlist.cn/wp-content/themes/domains, get_template_directory_uri(); 路径是:http://watchlist.cn/wp-content/themes/domains”; get_theme_file_path( ); 路径是:D:\wwwroot\watchlist.cn/wp-content/themes/domains; get_template_directory(); 路径是:D:\wwwroot\watchlist.cn/wp-content/themes/domains; get_template_directory_uri(); 路径是:http://watchlist.cn/wp-content/themes/domains; get_stylesheet_directory(); 路径是:D:\wwwroot\watchlist.cn/wp-content/themes/domains; get_stylesheet_directory_uri(); 路径是:http://watchlist.cn/wp-content/themes/domains

udemy wp course notes

Lectures Notes & Download Source Code for this Section Congratulations on making it this far! Just in case you have any problems, then you can download the source code for this section right here. Thanks for support! You can view all the lecture notes here just in case you need them. Please be sure to let me know […]

wordpress的walker

walker在任何程序里都存在,是一个方法将一个多级的array循环出来。wordpress本身有自带的walker, 很多时候要自定义walker. start element 函数和end element 函数会循环每个单个的类目,start lvl 和end lvl函数会被读取当循环数据开始时和结束时候, 不会循环,只是在循环开始时候和结束时候读取。 召唤walker的方式是在wp_nav_menu的函数里边, bootstrap的nav walker: 简单的walker class:(注意要在functions.php里面include进来或者require进来。

php中的\t和\n

\t告诉浏览器来tabhtml, \n 告诉浏览器把html放在新一行,也就是换行, php 中用作格式化,formating

WordPress walker documentation

Walker A class for displaying various tree-like structures. Description #Description Extend the Walker class to use it, see examples below. Child classes do not need to implement all of the abstract methods in the class. The child only needs to implement the methods that are needed. Top ↑ More Information #More Information The Walker class was implemented in WordPress 2.1 to provide developers […]

Wordress32个常用函数小技巧

What is Functions File in WordPress? Functions file commonly known as functions.php file is a WordPress theme file. It comes with all free and premium WordPress themes. The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your […]