On the WordPress Admin section how do I link to submenu pages created for a plugin?

admin_url() gets you the correct administration page URL (and network_admin_url() to get a network administration page URL) Optionally, you can use add_query_arg() to append arguments to an URL, using an associative array: $page=”edit_record_page”; $rec_id = 1; $record_url = add_query_arg(compact(‘page’, ‘rec_id’), admin_url(‘admin.php’));

How to not allow users to create new tags, but allow to them to use existing ones

You can hook onto pre_insert_term, check the taxonomy and whether or not the user has the specified role as follows: function disallow_insert_term($term, $taxonomy) { $user = wp_get_current_user(); if ( $taxonomy === ‘post_tag’ && in_array(‘somerole’, $user->roles) ) { return new WP_Error( ‘disallow_insert_term’, __(‘Your role does not have permission to add terms to this taxonomy’) ); } … Read more

how to query posts by category and tag?

Edit: See below for proper way to query category and tag intersections. global $wp_query; $args = array( ‘category__and’ => ‘category’, //must use category id for this field ‘tag__in’ => ‘post_tag’, //must use tag id for this field ‘posts_per_page’ => -1); //get all posts $posts = get_posts($args); foreach ($posts as $post) : //do stuff endforeach;

Posts with at least 3 tags of a list of tags

The answer below is simplified, and could be extended to check if any posts have 3 matching tags before outputting the list. Using one query and assuming you have at least one post with 3 matching tags: //List of tag slugs $tags = array(‘foo’, ‘bar’, ‘chocolate’, ‘mango’, ‘hammock’, ‘leaf’); $args = array( ‘tag_slug__in’ => $tags … Read more

The Difference Between Hierarchical and Non-Hierarchical Taxonomies?

The simple answer is that terms in hierarchical taxonomies can have child terms. But what else? ‘hierarchical’=>false When you specify a ‘hierarchical’=>false you get the following type of metabox which is the metabox format WordPress also uses for Post Tags: ‘hierarchical’=>true However when you specify ‘hierarchical’=>true you get the following type of metabox which is … 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