您的当前位置:首页 > 知识博客 > wordpress建站

WordPress函数the_content()和get_the_content()用法详解 (输出/打印文章内容函数)

时间:2024-03-19

75b20a79d997e31a556c9a5ef34dd3d5WordPress的the_content()函数

the_content() 函数是 WordPress 中的一个核心函数,用于显示文章的内容。它可以用在 WordPress 的模板文件中,具体用法如下:

<?php the_content(string $more_link_text = null, bool $strip_teaser = false); ?>

使用这个函数后,WordPress 会自动显示文章的内容,包括文字、图片和其他媒体。此外,它还可以添加分页符,如果文章过长,可以分成多个页面显示。

请注意,这个函数只能用于显示文章内容,如果要显示其他类型的内容,比如页面或自定义文章类型,需要使用其他函数,比如 the_page_content() 或 the_content_for_custom_post_type()。

注:the_content()函数位于:wp-includes/post-template.php

 

WordPress的get_the_content()函数

get_the_content() 函数是 WordPress 中的一个核心函数,用于显示文章的内容。它可以用在 WordPress 的模板文件中,具体用法如下:

<?php get_the_content(string $more_link_text = null, bool $strip_teaser = false); ?>

使用这个函数后,WordPress 会自动显示文章的内容,包括文字、图片和其他媒体。此外,它还可以添加分页符,如果文章过长,可以分成多个页面显示。

注:the_content()函数位于:wp-includes/post-template.php

the_content()和get_the_content()两个函数的关系


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 wangzhan.shop


Whatsapp
Powered by RRZCMS