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

文 / @WordPress主题

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()两个函数的关系

<?php //the_content() =  echo get_the_content() ; ?>

添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。