_x( 'Articalise', 'taxonomy general name' ), 'singular_name' => _x( 'Articalise', 'taxonomy singular name' ), 'search_items' => __( 'Search Articalise' ), 'popular_items' => __( 'Popular Articalise' ), 'all_items' => __( 'All Articalise' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Articalise' ), 'update_item' => __( 'Update Articalise' ), 'add_new_item' => __( 'Add New Articalise' ), 'new_item_name' => __( 'New Articalise Name' ), 'separate_items_with_commas' => __( 'Separate articalise with commas' ), 'add_or_remove_items' => __( 'Add or remove articalise' ), 'choose_from_most_used' => __( 'Choose from the most used articalise' ) ); register_taxonomy( 'articalise', array('post','page'), array( 'hierarchical' => true, 'labels' => $tax_labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'articalise' ), )); } add_filter( 'the_title', 'prefix_articalisation_to_title'); function prefix_articalisation_to_title($title, $id=null){ global $post; $opts = get_option('articalise'); // Only dissplay term (articalise group name) if we're in the loop. // This should avoid menu's e.t.c. if( in_the_loop() && $opts['title'] ){ $post_terms = wp_get_object_terms($post->ID, 'articalise'); if( is_single() && count($post_terms) > 0 ){ $term_name = $post_terms[0]->name; $title = $term_name.': '.$title; } } return $title; } add_filter( 'the_content', 'add_articalisation_to_posts' ); function add_articalisation_to_posts($content){ if( is_home() || is_singular() ){ $menu = get_articalise_menu(); $opts = get_option('articalise'); if( $opts['pre'] ) $content = $menu . $content; if( $opts['post']) $content = $content . $menu; } return $content; } function get_articalise_menu(){ global $post; $wp_cache_key = 'articalise_menu_'.$post->ID; $extra = wp_cache_get($wp_cache_key, 'articalise'); if( empty($extra) ){ $opts = get_option('articalise'); $post_terms = wp_get_object_terms($post->ID, 'articalise'); if( count($post_terms) > 0 ){ $term_id = $post_terms[0]->term_id; // Assume only ever one of these $term_name = empty($opts['alt']) ? $post_terms[0]->name : $opts['alt']; $term_slug = $post_terms[0]->slug; $sibling_objects = get_objects_in_term($term_id, 'articalise'); $article_pages = get_posts( array('include'=>$sibling_objects,'order'=>'ASC') ); if( count($article_pages) > 0 ){ $extra = '
'; } $adjust = empty($opts['adjust']) ? '' : 'articalise-'.$opts['adjust']; $extra = '