I am new to wordpress and cant figure out a way to grab data from the database.
I have set up a new php file.
I am using code from theme pages to get it the same way on the new file.php

global $post;
$dt_fields = get_post_meta($post->ID, 'fields', true);

so I am getting the id from the url and trying to retrieve details from the db I know I need to include some things to get this working but I really cant find what.

The error I get

PHP Fatal error: Call to undefined function get_post_meta()

Read more here: I’m trying to get data from database from php file


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: