【发布时间】:2015-03-25 19:52:08
【问题描述】:
我是 wordpress 的新手,我正在尝试创建我的第一个网站,我有一个带有 about 链接的 index.php 页面,该页面将从 wordpress 仪表板内创建的页面(帖子)中获取有关作者内容的信息,名称为 about。我正在使用 magnific popup 插件来处理 poups.. 我有 about.php,其中包含类似这样的关于页面的内容
关于.php
<?php
$pageid = 2; // 2 is the id of about page/post
$about = get_post($pageid);
?>
<div id="custom-content" class="white-popup-block" style="max-width:600px; margin: 20px auto;">
<h3><?php echo $about->post_title; ?></h3>
<style>
#custom-content img {max-width: 100%;margin-bottom: 10px;}
</style>
<div class="image-container pull-left">
<img src="<?php echo get_field( "image", $pageid ); ?>">
</div>
<h4><?php echo get_field( "brief", $pageid ); ?></h4>
<p>
<?php echo get_field( "brief_lines", $pageid ); ?>
</p>
<div class="about-content">
<?php echo $about->post_content; ?>
</div>
</div>
index.php
<a href="<?php echo get_template_directory_uri(); ?>/about.php" class="morelink pull-left text-ajax-popup">read more</a>
页脚.php
$('.text-ajax-popup').magnificPopup({
type: 'ajax',
alignTop: true,
overflowY: 'scroll'
});
点击链接后出现此错误
致命错误:调用未定义的函数 get_post()
我可以在 about.php 中包含哪些文件?有什么问题?
【问题讨论】:
-
我不使用 wordpress,所以我的建议非常有限,但从他们的文档codex.wordpress.org/Function_Reference/get_post 看来,您正在尝试在不包括 `wp-includes/post.php 或wp-includes/class-wp-atom-server.php``
-
我发现,文件 wp-blog-header.php 应该包含@chris85