[英]PHP - How do I get `<?php the_content(); ?>` as a string or turn it into a string
I use a lot the function: 我使用了很多功能:
get_search_query()
To get the value returned from searches and to be able to modify and use the string. 获取搜索返回的值,并能够修改和使用字符串。
I need to know a function to get <?php the_content(); ?>
我需要知道一个函数来获取
<?php the_content(); ?>
<?php the_content(); ?>
as a string or how to turn what that function returns into a string. <?php the_content(); ?>
作为字符串或如何将该函数返回到字符串中。
The content is just a simple word with paragraph tags but using that function I also get the tags, I want to get just the text so I can add it to a hyperlink. 内容只是一个带有段落标签的简单单词,但是使用该功能我也得到了标签,我想得到文本,所以我可以将它添加到超链接。
我想你正在寻找get_the_content()
,这是有据可查的: http : get_the_content()
如果您需要将其存储在具有html格式的变量中,请执行此操作
apply_filters('the_content',$post->post_content)
Don't know WP, but the implied naming convention would suggest get_the_content()
. 不知道WP,但隐含的命名约定会建议
get_the_content()
。 Additional googling reveals a variation get_the_content_with_formatting 额外的Google搜索显示了变体get_the_content_with_formatting
An alternative would be however to wrap the_content() into ob_start()
and ob_get_contents()+ob_end()
. 然而,另一种方法是将the_content()包装到
ob_start()
和ob_get_contents()+ob_end()
。 The latter returns any print
output made until then. 后者返回在此之前所做的任何
print
输出。
你应该使用get_the_content()来使它成为一个你可以格式化的字符串。
$the_post = get_post();
$the_post->post_content;
Full list of things you can get using this method: 使用此方法可以获得的完整列表:
[ID] =>
[post_author] =>
[post_date] =>
[post_date_gmt] =>
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] =>
[comment_status] =>
[ping_status] =>
[post_password] =>
[post_name] =>
[to_ping] =>
[pinged] =>
[post_modified] =>
[post_modified_gmt] =>
[post_content_filtered] =>
[post_parent] =>
[guid] =>
[menu_order] =>
[post_type] =>
[post_mime_type] =>
[comment_count] =>
[filter] =>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.