• Resolved donkey

    (@donkey)


    Hey, thanks for this plugin, it’s going to save me a lot of time adapting wordpress for angularjs.

    I had a problem, though. The post is being created, but the category is not being assigned to it. I modified your code somewhat to reflect my category IDs:

    $scope.data = {
    title: form.find('input[name="postTitle"]').val(),
    content_raw: form.find('textarea[name="postContent"]').val(),
    status: 'publish',
    post_category: [ 5 ]
    }

    And here is the resulting JSON that is sent:

    Array
    (
        [title] => Not again
        [content_raw] => Yes
        [status] => publish
        [post_category] => Array
            (
                [0] => 5
            )
    
    )

    https://www.ads-software.com/plugins/angularjs-for-wp/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Roy Sivan

    (@guavaworks)

    I’ll see if I can add this into the next version. thanks!

    Plugin Author Roy Sivan

    (@guavaworks)

    Added functionality to 1.1 with post-type You can now set a post type and it will grab all taxonomies associated to that post type, then create a select box so you can set.

    Only issue now is that the taxonomies are set AFTER save, so default category for posts (uncategorized) will be set… looking for a resolution.

    Ok, cool, thanks.

    Yeah, I had done a temporary fix using:

    wp_set_object_terms( $result, null, 'category' ); // Clear all existing categories
    wp_set_post_terms( $result, $data['post_category'], 'category', true );

    To clear out all categories and add the user-assigned ones. (I hadn’t gotten very far on the front-end, except for a simple text input.)

    Maybe you could use the first line or is that not a good fix?

    Plugin Author Roy Sivan

    (@guavaworks)

    I like that, the only issue is that I figured I’d take it one step to the next level and added in a post type with the creation. So a user can now set a custom post type, when you set a post type it only grabs taxonomies associated with that post type, if any.

    I can add in a post-type check and if it is include your line. I will think if there is a better solution.

    Plugin Author Roy Sivan

    (@guavaworks)

    resolving for now.

    Thread Starter donkey

    (@donkey)

    Oh duh, sorry, I was totally confused there. What I meant was that I had modified the json-rest-api plugin and added those two lines. Not really an option for you, I guess. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘No category assigned to new posts’ is closed to new replies.