Sui Go
Sui Go

Reputation: 463

Why I am having error Call to undefined function get_header() using wordpress?

I am using twenty eleven for my theme and I create a PHP page under it named results.php in the results.php here's my code:

    <?php

get_header(); ?>

<?php get_footer(); ?>

From my index.php:

    <?php get_header(); ?>
<a href="wp-content/themes/twentyeleven/result.php">Main</a>
<?php get_footer(); ?>

Upvotes: 1

Views: 2632

Answers (1)

jogesh_pi
jogesh_pi

Reputation: 9782

If you are making a custom page on the wordpress,

Then you have to set the template name into your file like in your result.php:

<?php
    /* Template Name: Result */
    get_header();

    // Rest Stuff for result.php

    get_footer();
?>

hope this will solve your problem..

UPDATE: Please don't use the direct link that you are given in your index.php file something like

<a href="wp-content/themes/twentyeleven/result.php">Main</a>

Because you are calling directly to the result.php but the best way is to create a page with the name Main from the backend and select the Result theme for that particular page.

Upvotes: 1

Related Questions