Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin

Question

I created a plugin TESTPLUGIN and added it on wordpress admin menu. I can access the plugin from the admin menu just well. The problem I am having is how to link to another file within the plugin. The file members.php is loaded by the add menu callback function. In this members.php I want to add a link to show_member.php load a single member when the name of a member is clicked. Both files are under one directory.

`<a href="<?php echo  plugin_dir_url(__FILE__).'show_member.php?id=4';?>">John Smit`h</a>
the url resolves to  **http://localhost/mywebsite/wp-content/plugins/myplugins/views/members.php** which is the correct path of show_member.php

But am getting this error message when I click the link:
Uncaught Error: Call to undefined function plugin_dir_path() in C:xampphtdocs...
I have also tried plugins_url() but got the same error. Can someone guide how I could link to another file within my wordpress plugin. What an I doing wrong? Thanks.

0
, , , , wafutech 4 years 2020-05-27T22:10:22-05:00 0 Answers 196 views 0

Leave an answer

Browse
Browse