• Been racking my brain (and google) trying to figure this out.

    What I want is for every post to automatically create a category that matches the post title. So, if I create a post title “Look at me” I want a category to be automatically created also called “Look at me”.

    I’ve tried using wp_set_object_terms like so:

    $cat_ids = array(9992);
    wp_set_object_terms( $post->ID, $cat_ids, echo get_the_title() );

    but no dice.

    Any ideas??

Viewing 1 replies (of 1 total)
  • Thread Starter chizet

    (@chizet)

    I’ve gotten relativly close:

    $post_id = 1;
    $cat = get_the_title($post_id);
    
    // Adding category to the post
    wp_set_object_terms( $post_id,  array("$cat"), 'category');

    Now I just need to replace the specific post ID with the current post’s ID – is that possible?

Viewing 1 replies (of 1 total)
  • The topic ‘Automatic category creation and category is post title’ is closed to new replies.