Custom Functions with Variables
-
WordPress 5.4.2
In PHP, I have created a custom function what requires variables. (it lists the files from a directory, very simple, but requires the directory to scan, and method for ordering and if it should display icons.) I use it on several pages, multiple times on each page.
This function is in an include file, which is include within a Custom HTML section.
In another Custom HTML section I would put in the code like:
[insert_php]getFilesList(‘testing/Documentation/’, ‘imageTitle’);[/insert_php]I update the post, view the page and everything looks great. Until I go back to edit the page. Then I get an error:
Fatal error: Uncaught Error: Call to undefined function getFilesList() in /webroot/prod/public/wordpress/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code:1 Stack trace: #0 /webroot/prod/public/wordpress/wp-content/plugins/insert-php/insert_php.php(48): eval() #1 /webroot/prod/public/wordpress/wp-includes/class-wp-hook.php(287): will_bontrager_insert_php(‘\napply_filters(‘\n
prepare_item_for_response(Object(WP_Post), Object(WP_REST_Request)) #5 /webroot/prod/public/wordpress/wp-includes/rest-api/class-wp-rest-server.php(1015): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request)) #6 /webroot/prod/pu in /webroot/prod/public/wordpress/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 1
- The topic ‘Custom Functions with Variables’ is closed to new replies.