2015-03-25 19:52
浏览 119


I'm new on wordpress and I'm trying to create my first website, I have an index.php page with about link, which will get about author content from created page (post) inside wordpress dashboard with name about. I'm using magnific popup plugin for poups.. I have about.php which includes content of about page like this


        $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>
    #custom-content img {max-width: 100%;margin-bottom: 10px;}
    <div class="image-container pull-left">
        <img src="<?php echo get_field( "image", $pageid ); ?>">
    <h4><?php echo get_field( "brief", $pageid ); ?></h4>
    <?php echo get_field( "brief_lines", $pageid ); ?>
    <div class="about-content">
        <?php echo $about->post_content; ?>


<a href="<?php echo get_template_directory_uri(); ?>/about.php" class="morelink pull-left text-ajax-popup">read more</a>


        type: 'ajax',
        alignTop: true,
        overflowY: 'scroll' 

after click on the link I got this error

Fatal error: Call to undefined function get_post()

Is there files could I include inside about.php ? what is the problem ?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • douliang2935 2015-03-26 05:10

    You're not loading WordPress.

    You need to build a theme instead of putting PHP files in the root directory. WordPress will setup the environment and then load your theme making functions like get_post() available to you without you having to include core files in every PHP file you create.

    Take a look at how the default themes are built to get a better understanding of what's involved.

    解决 无用
    打赏 举报

相关推荐 更多相似问题