如何在wordpress中的自定义主题中显示页面内容?

时间:2015-06-01 14:35:11

标签: php wordpress wordpress-plugin wordpress-theming content-type

我一直在搜索这几个小时,我可能会忽略它或在谷歌中提出错误的问题,但我真的想知道如何获取我输入的内容,例如WordPress仪表板中的“关于”页面,显示在我的page.php

2 个答案:

答案 0 :(得分:1)

如果您需要按ID显示特定的帖子/页面,Wordpress具有

功能
<?php get_post( $id, $output, $filter ); ?> 

此处的文档:https://codex.wordpress.org/Function_Reference/get_post

答案 1 :(得分:1)

您可以像这样获取任意页面的内容:

var marker1 = new google.maps.Marker({
  position: myLatLng,
  map: map,
  icon: {
    url: image,
    size: new google.maps.Size(134,130), //different sizes
  },
  zIndex: 2, //different overlays
  title: '1º marker',
});

我按标题抓取页面,您也可以获取by IDURL path

然后,您可以通过输出post object$page = get_page_by_title('About'); 属性来显示它。请注意,如果您需要格式化,则需要应用post_content过滤器:

the_content
相关问题