Adding categories to custom post type in permalink

There are 2 points of attack to cover when you are adding custom post type rewrite rules: Rewrite rules This happens when the rewrite rules are being generated in wp-includes/rewrite.php in WP_Rewrite::rewrite_rules(). WordPress allows you to filter the rewrite rules for specific elements like posts, pages and various types of archive. Where you see posttype_rewrite_rules … Read more

Get Category ID inside Category template

$wp_query->get_queried_object() will give you the “currently queried object”. On a category archive this is the category object, on a author page this is the author, on a single post this is the post itself, … well, you get the the idea. If you only want the ID you can also use $wp_query->get_queried_object_id().

Add custom field to Category

I posted an How To about it a week ago http://en.bainternet.info/2011/wordpress-category-extra-fields hope this helps. Ohad. Here are the details of the post: The first thing we need to do is add the extra fields to the category edit form using the hook edit_category_form_fields and we use a simple function that will print out the extra … Read more

How To Find Out WordPress Category Table in MYSQL?

See the Codex’s WordPress Taxonomy documentation. WordPress 2.3 replaced the previous categories, post2cat, and link2cat tables with three a more flexible set of taxonomy tables. wp_terms wp_term_relationships wp_term_taxonomy wp_terms– holds the basic information about single terms. term_id bigint(20) unsigned NOT NULL auto_increment, name varchar(200) NOT NULL default ”, slug varchar(200) NOT NULL default ”, term_group … Read more

List all subcategories from category

Yes, you can use get_categories() using ‘child_of’ attribute. For example all sub categories of category with the ID of 17: $args = array(‘child_of’ => 17); $categories = get_categories( $args ); foreach($categories as $category) { echo ‘<p>Category: <a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name … Read more

Adding Fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?

I added new field ‘picture’ (input type file) to category with help of these add_action(‘category_edit_form_fields’,’category_edit_form_fields’); add_action(‘category_edit_form’, ‘category_edit_form’); add_action(‘category_add_form_fields’,’category_edit_form_fields’); add_action(‘category_add_form’,’category_edit_form’); function category_edit_form() { ?> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(‘#edittag’).attr( “enctype”, “multipart/form-data” ).attr( “encoding”, “multipart/form-data” ); }); </script> <?php } function category_edit_form_fields () { ?> <tr class=”form-field”> <th valign=”top” scope=”row”> <label for=”catpic”><?php _e(‘Picture of the category’, ”); ?></label> … Read more

Get Posts Under Custom Taxonomy

Your tax query is incorrect, field should be the field you want to query on: term_id, name, or slug – $posts_array = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘fabric_building’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘fabric_building_types’, ‘field’ => ‘term_id’, ‘terms’ => $cat->term_id, ) ) ) );

Is There a Difference Between Taxonomies and Categories?

Taxonomies, as previously described are a collective noun for the following category post_tag post_format link_category custom taxonomy The first four are built-in taxonomies, while custom taxonomies are taxonomies that are manually created by the user with register_taxonomy. Custom Taxonomies can be hierarchical (like the build-in taxonomy category) or not (like post tags) The categories and … Read more