I need to call custom php script when I publish new post in WP. This function works, but include not. It is not included. Can it be working or is there any other way to include php file in functios.php?
function new_post_caller( $ID, $post ) {
include( get_template_directory() . 'call_new_post.php?ID='.$ID.'' );
}
add_action( 'publish_mypost', 'new_post_caller', 10, 2 );
If you want to include script and pass a parameter to him, you can create function in including script and use construction like this:
some script to include (file.php):
and calling file.php and pass a parameter:
Function include() simply adds the code from including file to the file where the function was originated
http://php.net/manual/en/function.include.php
Use
include( get_template_directory() . '/filetoinclude.php' );
It will work.
function include() can includes only php/html files for execute, without GET or POST parametrs.