WordPress error with require_once

Solution:

Your problem is that you are using a worng reletive path to the file wanted.

Try on using:

$filePath = get_bloginfo(‘template_url’); // this line gets you the path to the current theme.
$filePath .= ‘includes/theme-widgets.php’; // now we add the relative path to your file
require_once($filePath); // now we place the hole thing inside the ‘require_once’ function.

now you can minimize the code by:

require_once(get_bloginfo(‘template_url’).’includes/theme-widgets.php’);

what was originally responded by the function was that it was trying on going to: public_html/includes/theme-widgets.php which did not exist while your path was: public_html/wp-content/themes/{theme_name}/includes/theme-widgets.php

The code i have provided before should do the job for you 🙂