How do you add a category to a post in code

There’s the wp_update_post(), also. According to categories, please refer to the documentation. Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post. So, it would be something like: $post = get_post($i = $post_id); … Read more

How do you categorize pages?

You will only need a one basic function for the taxonomy, it’s really straightforward: register_taxonomy(). If you want to use a custom post type, it’s just as simple: register_post_type() For the widget, it’s a little more complicated. You’ll need to look at how to register widgets, and saving values and such. All of that is … Read more

Get Unique Categories – Group By?

How about doing something like this? //establish holders $clients = array(); $media = array(); //loop through gotten posts foreach( $clients_query as $k => $v ) { //add to clients array if( !in_array( get_client( $v ), $clients ) ) $clients[] = get_client( $v ); //add to media array if( !in_array( get_medium( $v ), $media ) ) … Read more

Limit a meta box to a specific category

You might want to check out his other post: http://www.farinspace.com/show-hide-meta-box-by-category/ I figure you would need some javascript because if you change categories, you would need some way for the browser to trigger to show the metabox, hence javascript. He has a video tutorial, so that should help explain everything. Also, since you are already reading … Read more

Is having thousands of unique categories a concern?

I’ve worked with sites that have thousands of categories and over 20K post tags. This really doesn’t deal with WordPress capability per se as much as server capacity and capability. Here’s what I would recommend: Install the W3TC Plugin Install memcached on your server Set W3TC to use object caching via memcached – you will … Read more

Exclude category from fucntion

foreach ($categories as $individual_category) { if( $individual_category->term_id == 81 || $individual_category->term_id == 82 ) continue; $category_ids[] = $individual_category->term_id; } explanation: the above replaces: foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; i.e. the code jumps over the to be excluded categories.

category filter doesn’t work in WPML

First you should upgrade WPML to the latest version, which is 2.4.3 at time of writing. To properly translate categories you should start by editing the category of the default language. Once you are in that screen (wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=x&post_type=post where x is the category ID), you will see at the bottom a metabox titled Language. This … Read more