I need to assign a default category to my custom post type.
i created this, but do not work:
function add_portfolio_category_automatically($post_ID) {
global $wpdb;
if(!has_term(”,’portfolio_category’,$post_ID)){
$cat = array(11);
wp_set_object_terms($post_ID, $cat, ‘portfolio_category’);
}
}
add_action(‘avada_portfolio’, ‘add_portfolio_category_automatically’);
Information:
custom post type taxonomies: avada_portfolio
custom post type taxonomies of category: portfolio_category
I wish all the posts had the category "car" as defaul.
I tried for hours without success.
$post_ID? your question is not clear - Halayem Anis