PHP-如何获取`<;?php_content()>;`或将其转换为字符串
我使用了很多函数:PHP-如何获取`<;?php_content()>;`或将其转换为字符串,php,wordpress,Php,Wordpress,我使用了很多函数: get_search_query() 获取搜索返回的值,并能够修改和使用字符串 我需要知道将作为字符串获取的函数,或者如何将该函数返回的内容转换为字符串 内容只是一个带有段落标记的简单单词,但使用该功能,我还可以获取标记,我只想获取文本,以便将其添加到超链接 我认为您正在寻找获取内容(),这一点有很好的文档记录:不知道WP,但隐含的命名约定建议获取内容()。额外的谷歌搜索揭示了一种变化 但是,另一种方法是将内容()包装成ob\u start()和ob\u get\u co
get_search_query()
获取搜索返回的值,并能够修改和使用字符串
我需要知道将
作为字符串获取的函数,或者如何将该函数返回的内容转换为字符串
内容只是一个带有段落标记的简单单词,但使用该功能,我还可以获取标记,我只想获取文本,以便将其添加到超链接 我认为您正在寻找
获取内容()
,这一点有很好的文档记录:不知道WP,但隐含的命名约定建议获取内容()
。额外的谷歌搜索揭示了一种变化
但是,另一种方法是将内容()包装成
ob\u start()
和ob\u get\u contents()+ob\u end()
。后者返回在此之前所做的任何print
输出。您应该使用get\u The\u content()将其转换为字符串,您可以对其进行格式化。如果需要将其存储在具有html格式的变量中,请执行此操作
apply_filters('the_content',$post->post_content)
使用此方法可以获得的内容的完整列表:
[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] =>
虽然这可能是最好的方法,但请注意,get_the_content()
并不仅仅是the_content()
返回内容而不是打印内容。一个重要的区别是获取内容()
不过滤内容。因此,例如,如果您使用短代码嵌入视频、联系人表单等,默认情况下,它们将无法使用这种方法。您还需要对内容运行apply\u过滤器(“内容”,…)
。可湿性粉剂法典中的更多信息:
[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] =>