I an newbie in PHP and I have the following in a template file.
$url = get_permalink(get_page_by_title('Main'));
But the above line gives me an error ..
Fatal error: Call to undefined function get_permalink() in C:\wamp\www\wordpress\wp-content\themes\twentysixteen\handleLogin.php
I tried including the file link-template
at the top by using the below line but it doesn't find the file either.
include_once 'wp-includes/link-template.php';
I googled but everyone seems to have it working .. those who complained were having typos in the function name which are not my cases.
Any help will be appreciated. Thanks.
I know this is a very old post. But posting if anyone comes looking for answers like me.
After requiring, wp-load.php add below,
require_once ABSPATH . WPINC . '/class-wp-rewrite.php';
require_once ABSPATH . WPINC . '/link-template.php';
require_once ABSPATH . WPINC . '/post.php';
require_once ABSPATH . WPINC . '/class-wp-post.php';
require_once ABSPATH . WPINC . '/category-template.php';
require_once ABSPATH . WPINC . '/taxonomy.php';
require_once ABSPATH . WPINC . '/l10n.php';
require_once ABSPATH . WPINC . '/formatting.php';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.