2429 posts
  • Has been a member for 4-5 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Microlancer Beta Tester
digitalimpact says
OK, so I can pull all the categories in, and say which category ID to apply… BUT I can not apply that to my custom post type? I have to declare the post id? I dont know that yet and want to apply it obviously to more than one post, all the posts from the custom post i created.

You just need to specify your custom post type. Say you have one called ‘designers’:

<?php $args = array(
    'type'                     ?> 'designers',
    'child_of'                 => 0,
    'orderby'                  => 'name',
    'order'                    => 'ASC',
    'hide_empty'               => 0, // get'em all
    'hierarchical'             => 1,
    'exclude'                  => ,
    'include'                  => ,
    'number'                   => ,
    'pad_counts'               => false );

?>
456 posts
  • Bought between 10 and 49 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
  • United Kingdom
godonholiday says

OK ill give that a go with the code from the previous link, thanks.

456 posts
  • Bought between 10 and 49 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
  • United Kingdom
godonholiday says

Sorry but I am still finding it hard to get my head around this.

The code below, in my functions file, will set the category id ‘4’ (‘Green’)to a post (I am not sure which post?).

$category_ids = array(4); wp_set_object_terms( $post_id, $category_ids, 'Green');

where do I set this to apply to my custom post type?

$category_ids = array(4, 5, 6); <?php $args = array( 'type' ?> 'designers', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, // get'em all 'hierarchical' => 1, 'exclude' => , 'include' => , 'number' => , 'pad_counts' => false ); ?> wp_set_object_terms( $args, $category_ids, 'category');

Like that?

by
by
by
by
by
by