your functions.php
should be in your theme directory, not in includes directory. Should be somewhere like wp-content/themes/YOUR_THEME/functions.php
How to add Custom Tags in Worpdress
Вопрос
I was trying to create custom tags for my wordpress application. I entered this piece of code to my functions.php:
function create_my_taxonomies() {
register_taxonomy('actors', 'post', array(
'hierarchical' => false, 'label' => 'Actors',
'query_var' => true, 'rewrite' => true));
register_taxonomy('producers', 'post', array(
'hierarchical' => false, 'label' => 'Producers',
'query_var' => true, 'rewrite' => true));
}
add_action('init', 'create_my_taxonomies', 0);
When I now try to access my admin panel, it throws me this error: Fatal error: Call to undefined function add_action() in C:\xampp\htdocs\wordpress\wp-includes\functions.php on line 4209
Then I checked and found that it's because of the add_action() function that it cant find. So I included require( ABSPATH . WPINC . '/plugin.php' ); at top of the functions.php
But now it throws me another error: Fatal error: Cannot redeclare add_filter() (previously declared in C:\xampp\htdocs\wordpress\wp-includes\plugin.php:82)
I tried looking up everywhere but I doesn't seem to find anything. Suggestions and help would be appreciated. Thanks in advance!
Решение
Другие советы
Instead of require
, try using require_once
to make sure the file is included only once.
require_once ( ABSPATH . WPINC . '/plugin.php' );