WordPress的the_content()函数报错,页面模板等

常用教程评论3,1761阅读模式

某些情况下,直接调用the_content或者get_the_content()会报错文章源自原紫番博客-https://www.yuanzifan.com/54515.html

<?php the_conent();?>

这种情况下需要使用以下的方法进行操作:文章源自原紫番博客-https://www.yuanzifan.com/54515.html

<?php echo $post->post_content;?>

get_option,从表里面获取文章源自原紫番博客-https://www.yuanzifan.com/54515.html

WordPress 2019 文章页模板所在位置文章源自原紫番博客-https://www.yuanzifan.com/54515.html

wp-content/themes/2019/single.php文章源自原紫番博客-https://www.yuanzifan.com/54515.html

循环获取指定分类目录文章列表文章源自原紫番博客-https://www.yuanzifan.com/54515.html

    <?php query_posts('cat=5&posts_per_page=7'); while(have_posts()): the_post(); ?>   
                <ul>                
                    <li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title();?></a></li>   
                    <?php endwhile; wp_reset_query(); ?>                  
                </ul>

其中cat=20代表分类ID,posts_per_page=4代表显示几条记录。文章源自原紫番博客-https://www.yuanzifan.com/54515.html

参数描述 输出效果
y 显示后面 2 位数字 03
Y 显示 4 位数字 2003
参数描述 输出效果
m 数字的,有前缀 0 06、12
n 数字的,没有前缀 0 6、12
F 月份全称(根据网站的语言是中文还是英文) 一月、十二月(January、December)
M 月份简写(根据网站的语言是中文还是英文) 一、十二(Jan、Dec)
参数描述 输出效果
d 数字的,有前缀 0 01、31
j 数字的,没有前缀 0 1、31
S 序列型数字的后缀 st、nd、rd 或 th
时间 参数描述 输出效果
a 小写上下午(根据网站的语言是中文还是英文) am、pm(上午、下午)
A 大写上下午(根据网站的语言是中文还是英文) AM、PM(上午、下午)
g 小时,12 小时制,没有前缀 0 6、12
h 小时,12 小时制,有前缀 0 06、12
G 小时,24 小时制,没有前缀 0 6、23
H 小时,24 小时制,有前缀 0 06、23
i 分,有前缀 0 01、59
s 秒,有前缀 0 01、59
T 时区/时间缩写 CST、EST、MDT...
O 时区 +0800
W 周数 22
z 天数 365
星期 参数描述 输出效果
l 星期全称(小写字母 L)(根据网站的语言是中文还是英文) 星期一、星期日(Monday、Sunday)
D 星期(根据网站的语言是中文还是英文) 周一、周日(Mon、Sun)
w 数字星期 0、6(注意:0 代表星期日)
完整的日期时间 参数描述 输出效果
r RFC 2822 Mon, 06 Jan 2010 20:05:09+0800
c ISO 8601 2004-02-12T15:19:21+00:00
文章源自原紫番博客-https://www.yuanzifan.com/54515.html文章源自原紫番博客-https://www.yuanzifan.com/54515.html
 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证