Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
|
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help. |
|
Thread Tools |
06-28-2013, 11:40 AM | #1 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Adding 2nd WP Custom Taxonomy?
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 ); ?>
__________________
www.tittytweaker.com |
06-28-2013, 11:53 AM | #2 | |
Confirmed User
Industry Role:
Join Date: May 2012
Posts: 124
|
Quote:
at second look just use register_taxonomy without wrapping it in a function to do what you want do you have skype i will explain to you easier |
|
06-28-2013, 12:18 PM | #3 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
I don't have skype, it's easier for me to just do it in here anyway since I can come back to it whenever it is convenient for me.
I think I get what you are saying though. However since I'm not familiar with PHP, I don't know where exactly I'm going to be putting the code, or even what the necessary chunk of code is. Can you show me exactly what part of the code needs to be copied and where it goes?
__________________
www.tittytweaker.com |
06-28-2013, 12:25 PM | #4 |
Confirmed User
Industry Role:
Join Date: May 2012
Posts: 124
|
i really dont know the full picture but I guess you could do a couple things
I suppose you could go to the other function declaration you did to add taxonomy and just register the model taxonomy in that one or if you want to just keep what you have for simplicity or whatever rename this add_custom_taxonomies to addModelTaxonomy() then use addModelTaxonomy in your init add_action( 'init', 'addModelTaxonomy'); i suppose its a workaround way but might be simplest for you I don't really want to get too deep into this |
06-28-2013, 02:20 PM | #5 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Well, the model taxonomy is the one I have already added, the one that functions. I'm just trying to add a new one. Again, I'm entirely unfamiliar with PHP, so I'd have to actually see the final / correct code in order to understand.
__________________
www.tittytweaker.com |
06-28-2013, 05:59 PM | #6 |
Confirmed User
Industry Role:
Join Date: Nov 2012
Posts: 107
|
Simply add following code to your functions.php in theme folder:
Code:
function some_custom_taxonomy_init() { // create a new taxonomy register_taxonomy( '<put_your_taxonomy_name_here>', 'post', array( 'label' => __( 'People' ), 'rewrite' => array( 'slug' => '<put_your_taxonomy_slug_here>' ), 'capabilities' => array( 'assign_terms' => 'edit_guides', 'edit_terms' => 'publish_guides' ) ) ); } add_action( 'init', 'some_custom_taxonomy_init' ); <put_your_taxonomy_slug_here> - change this (this will be displayed in link domain.com/this_taxonomy/) note: this taxonomy will be added to default post type (Post) name of the functions must be unique, now is "some_custom_taxonomy_init"
__________________
To contact me use email: 4spankalot [at] gmail [dot] com |
06-29-2013, 08:32 AM | #7 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Thanks for the clarification. I get what you mean. I'm now able to add that taxonomy, however, now I get this error at the top of my screen:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/42/10173742/html/wp-content/themes/adultphoto-01-pink/functions.php:168) in /home/content/42/10173742/html/wp-content/plugins/easy-batch-uploader-0.4.0/class-main.php on line 135 It's interfering with a custom plugin. I e-mailed the guy who made it, still waiting for a reply - but figured I'd mention it here too. Do you guys think this is a problem with the taxonomy I made, or with the plugin? Considering my other custom taxonomy didn't interfere with the plugin, I'm thinking I'm still doing something wrong with the new one. This is the code that I have added: Code:
<?php /** * Add custom taxonomies * * Additional custom taxonomies can be defined here * http://codex.wordpress.org/Function_Reference/register_taxonomy */ function add_custom_taxonomies_site_init() { // Add new "Site" taxonomy to Posts register_taxonomy('Site', '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( 'Site', 'taxonomy general name' ), 'singular_name' => _x( 'Site', 'taxonomy singular name' ), 'search_items' => __( 'Search Site' ), 'all_items' => __( 'All Site' ), 'parent_item' => __( 'Parent Site' ), 'parent_item_colon' => __( 'Parent Site:' ), 'edit_item' => __( 'Edit Model' ), 'update_item' => __( 'Update Site' ), 'add_new_item' => __( 'Add New Site' ), 'new_item_name' => __( 'New Site Name' ), 'menu_name' => __( 'Site' ), ), // Control the slugs used for this taxonomy 'rewrite' => array( 'slug' => 'site', // 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_site_init', 0 ); ?>
__________________
www.tittytweaker.com |
06-29-2013, 11:09 AM | #8 |
Confirmed User
Industry Role:
Join Date: Nov 2012
Posts: 107
|
There's nothing wrong with the taxonomy. The error means that you have printed something out before the headers were sent meaning that there's some kind of print/echo command in your functions.php file... check the error code lines.
__________________
To contact me use email: 4spankalot [at] gmail [dot] com |
06-29-2013, 01:07 PM | #9 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
I manged to fix it by combining the two custom taxonomy chunks into one chunk of php code, I think. Basically took out the closing tags of the first one, and the opening tags of the second. Corresponded to the line error, so I guess that was it.
Now I'm getting an error when I try to use get_the_term_list to display the taxonomy on a page. : Catchable fatal error: Object of class WP_Error could not be converted to string in /home/content/42/10173742/html/wp-content/themes/adultphoto-01-pink/single.php on line 45 The code is: Code:
<div class="image-site"><?php $site_list = get_the_term_list( $post->ID, 'site', 'Site: ', ', ', '' ); // Output taxonomy information if there was any if ( '' != $site_list ) { echo $site_list; } // endif ?> </div> Thanks for being patient with me, this php stuff is just way over my head, difficult to grasp.
__________________
www.tittytweaker.com |
06-30-2013, 08:55 AM | #10 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Bump. Anyone?
__________________
www.tittytweaker.com |
07-01-2013, 09:09 AM | #11 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Anyone? Still getting this error. I also can't view the results for that archive page. If I go to a term that I know has posts in it, it still says there were no results.
__________________
www.tittytweaker.com |
07-02-2013, 09:14 AM | #12 |
Confirmed User
Industry Role:
Join Date: Dec 2012
Posts: 184
|
Figured it all out. For anyone who finds this post who has similar problems, find an auto taxonomy code generator, just so you can be sure you aren't messing anything up yourself. Then refresh the permalink structure. That fixed everything for me. Such an easy fix, just had to find it.
__________________
www.tittytweaker.com |