Wordpress | get_user_meta in child themes php file

112 Views Asked by At

I'm trying to get the user meta in a file calles "print.php" in my child-theme folder:

define( 'WP_USE_THEMES', true ); 
$userid = $_GET['id'];
//$all_meta = get_user_meta( $userid );

When I call "get_user_meta()" i get an Error 500.

I already tried with

define('WP_USE_THEMES', false);
require('./wp-blog-header.php');

and

define('WP_USE_THEMES', false);
require('./wp-load.php');

What am I doing wrong and how can I resolve it?

Also tried already to put a function in my functions.php and call this function. No luck.

I hope you can help me.

Thanks and best regards,

Niko

1

There are 1 best solutions below

1
On

You must include the wp_head() Function on top of your index.php / function.php. So that you can use WordPress Funktions. See the documentation here

https://developer.wordpress.org/reference/functions/wp_head/