ThemeShaper Forums » Thematic

[closed]

Custom Taxonomies not showing in single.php

(6 posts)
  • Started 8 years ago by mrc2407
  • Latest reply from yilmaznakliyat
  • This topic is not resolved
  1. mrc2407
    Member

    Hi!

    I'm using the Easy Post Types plugin to create custom post types and custom taxonmies, but when I go to the custom post type single page (I'm using default single.php), custom taxonomies don't show up. There's an example here:

    http://nuvolsgratis.cat/proves/sensesal/canco/autobus-121/

    If you check the post footer, it says: This entry was published in ." And my custom taxonomy doesn't appear.

    Any idea on how to solve this? Thanks!

    Posted 8 years ago #
  2. Ok, in thematic/library folder, you'll find a folder called extensions. In content-extensions.php at around line 957 you should find:

    // Information in Post Footer
    if (function_exists('childtheme_override_postfooter'))  {
    	function thematic_postfooter() {
    		childtheme_override_postfooter();
    	}

    With me?

    This tells us that the first thing that will happen is that if function childtheme_override_postfooter() is found in your child theme functions.php, the override will be used instead of the default which follows below. The only reason to use a childtheme_override_postfooter() is if you have definite changes that need to be made to the postfooter.
    Since the postfooter only provides for:
    a) editlink at the bottom of pages for logged-in users
    b) list of categories (else "Uncategorized")
    c) list of post tags (else "Untagged")
    d) reply to link and list of comments and/or trackbacks (if permitted)
    e) edit link for post

    Since thematic_postfooter does not provide for a list of custom taxonomies out of the box, you will have to alter the postfooter with an override. I had to do this, because my custom post types are not associated with the default posttags and categories. I have custom taxonomies called portfolio-tag (Label Name: Tags) and portfolio-category ((Label Name: Categories).
    Here is an example of singular custom post type "painting":
    http://ridgelyschantz.com/painting/catapult-for-memory/

    Here is what my override functions look like:

    function childtheme_override_postfooter()	{
    			global $id,	$post;
    			if (is_singular()	&& $post->post_type	== 'drawing' ||	$post->post_type ==	'painting' ) {
    							$postfooter	=	'<div	class="entry-utility">';
    							$postfooter	.= '<p class="utilitax portmed">'	.	rs_postfooter_portmedium()	.	'</p>';
    							$postfooter	.= '<p class="utilitax portsurf">' . rs_postfooter_portsurfs()	.	'</p>';
    							$postfooter	.= '<p class="utilitax portcat">'	.	rs_postfooter_portcats()	.	 '</p>';
    							$postfooter	.= '<p class="utilitax porttag">'	.	rs_postfooter_porttags() . '</p>';
    							$postfooter	.= '<p class="postcon">' . thematic_postfooter_postconnect() . '</p>';
    							$postfooter	.= "</div><!-- .entry-utility	-->\n";
    				}	elseif ( $post->post_type	== 'drawing' ||	$post->post_type ==	'painting' ) {
    							$postfooter	=	'<div	class="entry-utility">';
    							$postfooter	.= '<p class="utilitax portmed">'	.	rs_postfooter_portmedium()	.	'</p>';
    							$postfooter	.= '<p class="utilitax portsurf">' . rs_postfooter_portsurfs()	.	'</p>';
    							$postfooter	.= '<p class="utilitax portcat">'	.	rs_postfooter_portcats()	.	 '</p>';
    							$postfooter	.= '<p class="utilitax porttag">'	.	rs_postfooter_porttags() . '</p>';
    							$postfooter	.= '<p class="postcom">' . thematic_postfooter_postcomments()	.	'</p>';
    							$postfooter	.= "</div><!-- .entry-utility	-->\n";
    			 } elseif	($post->post_type	== 'page'	&& current_user_can('edit_posts')) { /*	For	logged-in	"page" search	results	*/
    					$postfooter	=	'<div	class="entry-utility">'	.	thematic_postfooter_posteditlink();
    					$postfooter	.= "</div><!-- .entry-utility	-->\n";
    			}	elseif ($post->post_type ==	'page')	{	/* For logged-out	"page" search	results	*/
    					$postfooter	=	'';
    			}	else {
    					if (is_single()	&& $post->post_type	== 'post') {
    							$postfooter	=	'<div	class="entry-utility">';
    							$postfooter	.= '<p class="cat-tags">';
    							$postfooter	.= thematic_postfooter_postcategory();
    							$postfooter	.= '&nbsp;';
    							$postfooter	.= thematic_postfooter_posttags();
    							$postfooter	.= '</p>';
    							$postfooter	.= '<p class="postcoda">';
    							$postfooter	.= thematic_postfooter_postconnect();
    							$postfooter	.= '</p>';
    			 } else	{
    							$postfooter	=	'<div	class="entry-utility">';
    							$postfooter	.= thematic_postfooter_postcategory()	.	thematic_postfooter_posttags()	.	thematic_postfooter_postcomments();
    					}
    					$postfooter	.= "</div><!-- .entry-utility	-->\n";
    			}
    		 echo	apply_filters('childtheme_override_postfooter',	$postfooter);
    	 }
    // end postfooter
    
    function rs_postfooter_portmedium()	{
    		$portmedium	=	'<span class="medium-links">';
    		if (is_singular()	|| is_tax()	&& get_post_type ==	'drawing'	|| 'painting'	)	{
    		$termtext	=	__('Medium(s)',	'thematic');
    		$portmedium	.= get_the_term_list(	$post->ID, 'medium', " $termtext &nbsp;	"	,	',	', ''	);
    		$portmedium	.= '</span>';
    		}
    		return apply_filters('rs_postfooter_portmedium', $portmedium );
    }
    function rs_postfooter_portsurfs() {
    		$surfsup = '<span	class="surfsup-links">';
    		if (is_singular()	|| is_tax()	&& get_post_type ==	'drawing'	|| 'painting'	)	{
    		$termtext	=	__('Surface	Support(s) &nbsp;',	'thematic');
    		$surfsup .=	get_the_term_list( $post->ID,	'surface-support', "$termtext	"	,	',	', ''	);
    		$surfsup .=	'</span>';
    		}
    		return apply_filters('rs_postfooter_portsurfs',	$surfsup );
    }
    
    function rs_postfooter_portcats()	{
    			 $portcat	=	'<span class="portcat-links">';
    			if (is_singular()	&& get_post_type() ==	'drawing'	|| 'painting'	)	{
    					$portcat .=	__('Posted in	', 'thematic') . get_the_term_list($post->ID,	'portfolio-category',	'	', ',	', '');
    					$portcat .=	'</span>';
    			}	else {
    					$portcat .=	__('Posted in	', 'thematic') . get_the_term_list($post->ID,	'portfolio-category',	'	', ',	', '');
    					$portcat .=	'</span> <span class="meta-sep meta-sep-tag-links">	&bull; </span>';
    			}
    			return apply_filters('rs_postfooter_portcats',$portcat); 
    
    	}
    
    function rs_postfooter_porttags()	{
    
    			if (is_singular()	&& get_post_type() ==	'drawing'	|| 'painting'	)	{
    					$termtext	=	__(' Tagged	', 'thematic');
    					$porttags	=	get_the_term_list($post->ID, 'portfolio-tag',	"<span class=\"porttag-links\">	$termtext	",', ','</span>');
    			}	else {
    					$termtext	=	__('Tagged ',	'thematic');
    					$porttags	=	get_the_term_list($post->ID, 'portfolio-tag',	"<span class=\"porttag-links\">	$termtext	",', ','</span>	<span	class="meta-sep	meta-sep-comments-link"> &bull;	</span>');
    			}
    			return apply_filters('rs_postfooter_porttags',$porttags);
    	}
    
    function childtheme_override_postfooter_postconnect()	{
    			$postconnect .=	'<p	class="plink">';
    			$postconnect .=	__('Bookmark the ',	'thematic')	.	'<a	href="'	.	apply_filters('the_permalink', get_permalink())	.	'" title="'	.	__('Permalink	to ',	'thematic')	.	the_title_attribute('echo=0')	.	'">';
    			$postconnect .=	__('Permalink',	'thematic')	.	'</a>.';
    			$postconnect .=	'</p>';
    			if ((comments_open())	&& (pings_open())) { /*	Comments are open	*/
    					$postconnect .=	'	<a class="comment-link"	href="#respond"	title	="'	.	__('Post a comment', 'thematic') . '">'	.	__('Post a comment', 'thematic') . '</a>';
    					$postconnect .=	__(' or	leave	a	', 'thematic');
    					$postconnect .=	'<a	class="trackback-link" href="' . get_trackback_url() . '"	title	="'	.	__('Trackback	URL	for	your post',	'thematic')	.	'" rel="trackback">' . __('	trackback',	'thematic')	.	'</a>.&nbsp	&nbsp; ';
    			}	elseif (!(comments_open()) &&	(pings_open()))	{	/* Only	trackbacks are open	*/
    					$postconnect .=	__(' Comments	are	closed,	but	you	can	leave	a	', 'thematic');
    					$postconnect .=	'<a	class="trackback-link" href="' . get_trackback_url() . '"	title	="'	.	__('Trackback	URL	for	your post',	'thematic')	.	'" rel="trackback">' . __('	trackback',	'thematic')	.	'</a>.&nbsp	&nbsp; ';
    			}	elseif ((comments_open())	&& !(pings_open()))	{	/* Only	comments open	*/
    					$postconnect .=	__(' Trackbacks	are	closed,	but	you	can	', 'thematic');
    					$postconnect .=	'<a	class="comment-link" href="#respond" title ="' . __('Post	a	comment',	'thematic')	.	'">' . __('post	a	comment',	'thematic')	.	'</a>.';
    			}	elseif (!(comments_open()) &&	!(pings_open())) { /*	Comments and trackbacks	closed */
    					$postconnect .=	__(' Both	comments and trackbacks	are	currently	closed.',	'thematic');
    			}
    			// Display edit	link on	single posts
    			if (current_user_can('edit_posts'))	{
    					$postconnect .=	'	'	.	thematic_postfooter_posteditlink();
    			}
    			return apply_filters('childtheme_override_postfooter_postconnect'	,	$postconnect);
    	}
    
    function childtheme_override_postfooter_postcategory() {
    //We're	changing those separators, dammit!
    			$postcategory	=	'<span class="cat-links">';
    			if (is_single()) {
    					$postcategory	.= __('This	entry	was	posted in	', 'thematic') . get_the_category_list(',	');
    					$postcategory	.= '</span>';
    			}	elseif ( is_category() &&	$cats_meow = thematic_cats_meow(', ')	)	{	/* Returns categories	other	than the one queried */
    					$postcategory	.= __('Also	posted in	', 'thematic') . $cats_meow;
    					$postcategory	.= '</span>	<span	class="meta-sep	meta-sep-tag-links"><strong>&bull;</strong></span>';
    			}	else {
    					$postcategory	.= __('Posted	in ',	'thematic')	.	get_the_category_list(', ');
    					$postcategory	.= '</span>	<span	class="meta-sep	meta-sep-tag-links"><strong>&bull;</strong></span>';
    			}
    			return apply_filters('childtheme_override_postfooter_postcategory',$postcategory);
    	}
    
    function childtheme_override_postfooter_posttags() {
    //Again! Again!
    			if (is_single()) {
    					$tagtext = __('	and	tagged', 'thematic');
    					$posttags	=	get_the_tag_list("<span	class=\"tag-links\"> $tagtext	",', ','</span>');
    			}	elseif ( is_tag()	&& $tag_ur_it	=	thematic_tag_ur_it(',	') ) { /*	Returns	tags other than	the	one	queried	*/
    					$posttags	=	'<span class="tag-links">' . __('	Also tagged	', 'thematic') . $tag_ur_it	.	'</span> <span class="meta-sep meta-sep-comments-link"><strong>&bull;</strong></span>';
    			}	else {
    					$tagtext = __('Tagged',	'thematic');
    					$posttags	=	get_the_tag_list("<span	class=\"tag-links\"> $tagtext	",', ','</span>	<span	class="meta-sep	meta-sep-comments-link"><strong>&bull;</strong></span>');
    			}
    			return apply_filters('childtheme_override_postfooter_posttags',$posttags);
    	}
    
    function childtheme_override_postfooter_postcomments() {
    		 if	(comments_open())	{
    				 $postcommentnumber	=	get_comments_number();
    				 if	($postcommentnumber	>	'1') {
    							$postcomments = ' <p	class="commentnumb oneplus"> ';
    							$postcomments .=	'	<span	class="comments-link"><a	href="'	.	apply_filters('the_permalink', get_permalink())	.	'#comments"	title="' . __('Speak your	mind about	', 'thematic') . the_title_attribute('echo=0') . '">';
    							$postcomments .=	get_comments_number()	.	__(' Comments',	'thematic')	.	'</a></span>';
    				 } elseif	($postcommentnumber	== '1')	{
    							$postcomments = ' <p	class="commentnumb justone"> ';
    							$postcomments .=	'	<span	class="comments-link"><a	href="'	.	apply_filters('the_permalink', get_permalink())	.	'#comments"	title="' . __('Speak your	mind about	', 'thematic') . the_title_attribute('echo=0') . '">';
    							$postcomments .=	get_comments_number()	.	__(' Comment', 'thematic') . '</a></span>';
    				 } elseif	($postcommentnumber	== '0')	{
    							$postcomments	=	'	<span	class="comments-link"><a href="' . apply_filters('the_permalink',	get_permalink()) . '#comments" title="'	.	__('Speak	your mind	about	',	'thematic')	.	the_title_attribute('echo=0')	.	'">';
    							$postcomments	.= __('Leave a comment', 'thematic') . '</a></span>';
    					}
    		 } else	{
    					$postcomments	=	'	<span	class="comments-link comments-closed-link">' . __('Comments	Closed', 'thematic') .'</span>';
    			}
    			// Display edit	link
    			if ($postcommentnumber	>=	'1' && current_user_can('edit_posts'))	{
    					$postcomments	.= ' <span class="meta-sep meta-sep-edit"> <strong>&bull;</strong> </span> ' . thematic_postfooter_posteditlink();
    					$postcomments .= '</p>';
    			}	else {
    					$postcomments	.= ' <span class="meta-sep meta-sep-edit"> <strong>&bull;</strong> </span> ' . thematic_postfooter_posteditlink();
    			}
    			return apply_filters('childtheme_override_postfooter_postcomments',$postcomments);
    	}

    Hope this helps.

    Posted 8 years ago #
  3. mrc2407
    Member

    Mhhhhh... It's a really long code, this one... So, if childtheme_override_postfooter() is defined, Thematic will use this one instead of the original... so you mean I should copy the original function to my functions.php file and then modify it to fit my needs, right?

    After that, I just have to modify some function, just like rs_postfooter_portcats(), to get all my coustom taxonomies...

    But I don't understand why you copied the function childtheme_override_postfooter_postconnect() and the rest... I mean, I don't need to use them unless I want to edit some HTML, yes?

    Thnks for your support :) I almost had given it up...

    Posted 8 years ago #
  4. I needed to edit some html. I needed the postconnect stuff to exist in its own paragraph instead of running together. I realize this is a huge amount of code. I had a lot I wanted to change so this is how I did it.

    Posted 8 years ago #
  5. butters81
    Member

    Hi,

    I've found the following page really useful:
    http://bajada.net/2010/08/06/how-to-list-a-custom-post-types-taxonomies-and-terms

    Drop his code into your functions.php, and then add "ucc_get_terms()" into your childtheme override. This is really quick & dirty (and will probably break a load of stuff) but will give you the idea:

    // add custom taxonomies to categories & posts
    function childtheme_override_postfooter_postcategory() {
    
    	    $postcategory = '<span class="cat-links">';
    	    if (is_single()) {
    	        $postcategory .= __('This entry was posted in ', 'thematic') . ucc_get_terms_list(). get_the_category_list(', ');
    	        $postcategory .= '</span>';
    	    } elseif ( is_category() && $cats_meow = thematic_cats_meow(', ') ) { /* Returns categories other than the one queried */
    	        $postcategory .=  ucc_get_terms_list();
    			$postcategory .= __('Also posted in ', 'thematic') . $cats_meow;
    	        $postcategory .= '</span> <span class="meta-sep meta-sep-tag-links">|</span>';
    	    } else {
    	        $postcategory .= __('Posted in ', 'thematic') . ucc_get_terms_list(). get_the_category_list(', ');
    	        $postcategory .= '</span> <span class="meta-sep meta-sep-tag-links">|</span>';
    	    }
    	    return apply_filters('thematic_postfooter_postcategory',$postcategory); 
    
    }
    Posted 8 years ago #
  6. Thank you.very good.

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.