2468 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+2 more
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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
godonholiday says

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

456 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
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?

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by