I'm a bit confused. I've added a custom taxonomy called "models", and now I'm trying to add a new one, but when I do that I get this:
Fatal error: Cannot redeclare add_custom_taxonomies() (previously declared in /home/content/42/10173742/html/wp-content/themes/adultphoto-01-pink/functions.php:139) in /home/content/42/10173742/html/wp-content/themes/adultphoto-01-pink/functions.php on line 198
I'm sure this has to do with my lack of knowledge regarding PHP, I'm probably doing something wrong when I try to add it. Here is the code from my theme functions page as it is now:
Code:
<?php
//Short titles for preview link
function short_title($after = '', $length) {
$mytitle = get_the_title();
if ( strlen($mytitle) > $length ) {
$mytitle = substr($mytitle,0,$length);
echo rtrim($mytitle).$after;
} else {
echo $mytitle;
}
}
//Removing useless CSS that WP pasts right inside BODY tags... (?)
function remove_gallery_css( $css ) {
return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
}
add_filter( 'gallery_style', 'remove_gallery_css' );
//Post thumbsnails support
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
//Left sidebar
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Left Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>'));
}
//Right sidebar
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Right Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>'));
}
//Main menu
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array( 'header-menu' => __( 'Header Menu' ))
);
}
//Thanks to http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ for pagination function
function pagination($pages = '', $range = 9)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<span>Page ".$paged." of ".$pages."</span>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
}
}
//Cumstom comments template
function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 64 ); ?>
<span class="comment-author"><?php comment_author_link() ?> says:
<?php if ($comment->comment_approved == '0') : ?>
<em>(!) your comment is awaiting moderation</em>
<?php endif; ?>
</span>
<small class="comment-data"><a href="#comment-<?php comment_ID() ?>" title="Permanent link to this comment"><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a><?php edit_comment_link('Edit', ' | ', ''); ?></small>
<?php comment_text() ?>
<div class="clear"></div>
</li>
<?php
}
/**
* Add custom taxonomies
*
* Additional custom taxonomies can be defined here
* http://codex.wordpress.org/Function_Reference/register_taxonomy
*/
function add_custom_taxonomies() {
// Add new "Model" taxonomy to Posts
register_taxonomy('model', 'post', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => false,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Model', 'taxonomy general name' ),
'singular_name' => _x( 'Model', 'taxonomy singular name' ),
'search_items' => __( 'Search Model' ),
'all_items' => __( 'All Model' ),
'parent_item' => __( 'Parent Model' ),
'parent_item_colon' => __( 'Parent Model:' ),
'edit_item' => __( 'Edit Model' ),
'update_item' => __( 'Update Model' ),
'add_new_item' => __( 'Add New Model' ),
'new_item_name' => __( 'New Model Name' ),
'menu_name' => __( 'Model' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'model', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/model/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_custom_taxonomies', 0 );
?>
I'm trying to add a taxonomy called "Site", and I'm basically just copying and pasting the same chunk of taxonomy code and changing everything to "site" instead of "model". Can anyone tell me what's happening / what I need to do?