我已经搜索了几个小时, 我可能只是忽略了它或在Google中问了错误的问题, 但我真的很想知道如何获取输入的内容, 例如WordPress信息中心中的”关于”页面, 以显示在我的page.php中。
#1
你可以这样获取任意页面的内容:
$page = get_page_by_title('About');
我按标题抓取页面, 也可以按ID或URL路径获取页面
然后, 你可以通过输出post对象的post_content属性来显示它。请注意, 如果需要对其进行格式化, 则需要应用the_content过滤器:
echo apply_filters('the_content', $page->post_content);
#2
如果你需要按ID显示特定的帖子/页面, 则Wordpress具有此功能
<?php get_post( $id, $output, $filter ); ?>
此处的文档:https://codex.wordpress.org/Function_Reference/get_post
来源:
https://www.srcmini02.com/67330.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_36918.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57