Call to undefined function add_action()
-
i am getting this error when I am trying to access it from different php file apart from functions.php.
My folder structure is
Theme-name
————> css
————> js
————> includes/query.php
————>functions.phpwhereas inside query.php I HAVE Written following code
<?php
if (isset($_POST[‘q_first_name’])) {
$first_name = filter_var($_POST[‘q_first_name’], FILTER_SANITIZE_STRING);
$last_name = filter_var($_POST[‘q_last_name’], FILTER_SANITIZE_STRING);
$query_email_id = filter_var($_POST[‘q_email_id’], FILTER_SANITIZE_STRING);
$query_subject = filter_var($_POST[‘q_subject’], FILTER_SANITIZE_STRING);
$query_description = filter_var($_POST[‘q_description’], FILTER_SANITIZE_STRING);$query_name=$first_name.’ ‘.$last_name;
//$custom= get_post_custom($post_id);
}
add_action(‘save_post’,’save_post_callback’);
function save_post_callback($post_id){
global $post;
if ($post->post_type != ‘query’){
return;
}
$id=wp_insert_post(array(
‘post_status’ => ‘publish’,
‘post_type’ => ‘query’,
‘post_title’ => ‘Some post’,
‘post_content’ => ‘Lorem ipsum’
));}
If I use only wp_insert_post() then it is showing same error for wp
_insert_post().
- The topic ‘Call to undefined function add_action()’ is closed to new replies.