Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

Custom taxonomies

  1. Hi Justin. On my recipe site i have migrated from the lovely Options to the lovelier Hybrid and im using 4 costum taxonomies, according to the tutorial on you personal site.

    Is there a way NOT to show the taxonomies, if the category in view is not recipes?

    It looks a little..hmm....wierd to have them displayed on an article post.

  2. You must be a logged-in exclusive member to view this reply.

  3. Hmm....

    In functions.php the code looks like this:

    <?phpadd_action( 'init', 'create_my_taxonomies', 0 );function create_my_taxonomies() { register_taxonomy( 'oprindelse', 'post', array( 'hierarchical' => false, 'label' => 'Oprindelse', 'query_var' => true, 'rewrite' => true ) ); register_taxonomy( 'type', 'post', array( 'hierarchical' => false, 'label' => 'Type ret', 'query_var' => true, 'rewrite' => true ) ); register_taxonomy( 'season', 'post', array( 'hierarchical' => false, 'label' => 'S&aelig;son', 'query_var' => true, 'rewrite' => true ) ); register_taxonomy( 'ingredienser', 'post', array( 'hierarchical' => false, 'label' => 'Ingredienser', 'query_var' => true, 'rewrite' => true ) );}?><?php remove_filter( 'pre_term_description', 'wp_filter_kses' ); ?>

    in the single.php the look like this:

    <div class="tagsleft"><?php echo get_the_term_list( $post->ID, 'ingredienser', '<strong>Ingredienser:</strong><p> ', ', ', '</p>' ); ?> <?php echo get_the_term_list( $post->ID, 'type', '<strong>Type ret:</strong><p> ', ', ', '</p>' ); ?></div> <div class="tagsright"><?php echo get_the_term_list( $post->ID, 'oprindelse', '<strong>Oprindelse:</strong><p> ', ', ', '</p>' ); ?> <?php echo get_the_term_list( $post->ID, 'season', '<strong>S&aelig;son:</strong><p> ', ', ', '</p>' ); ?></div> <strong>Giv opskriften en karakter</strong> <?php if(function_exists('the_ratings')) { the_ratings(); } ?> </div>

    and the category ID is 1

    Best regards,
    Kristian

  4. You must be a logged-in exclusive member to view this reply.

  5. say what?
    but, but.....before i do that let me ask 1 thing.

    Im using the leviathan childtheme, custumized for my needs, so you still want me to delete hybrid or leviathan?

  6. 1 more thing? Should i upgrade Wp to 2.8.2 aswell?

  7. You must be a logged-in exclusive member to view this reply.

  8. Hi again justin,
    I have upgraded wordpress to 2.8.2, deleted the old hybrid theme and uploaded a new one.

    I would like the taxonomies only to be displayed either in category ID 1 or post tag ID 3 at the bottom of the page in single.php.

    It looks really stupid to have ingredients, season, type of meal and origin displayed on a post article about fish and its use and fressnes, if you understand.

    Best regards, and thank you in advance for the help.

    I made a new css style called .post-meta-data1 to style the ratings and custom taxonomies

  9. Justin, as i wrote i just deleted and uploaded a new version of hybrid.
    Now it seems that when i edit an existing page, it doesnt show up anymore - the link is there, but no text.

    Also im using the hybrid seo settings because they are truly the best, but after editing a page they seem to disappear.
    I mean, they are there in the fields, but the fields where you write them in, empties out after saving the page, and that didnt happend before.....

    I also forgot to mention that i copied single.php from hybrid to leviathan - should i delete that aswell - i was thinking about the taxonomies....

  10. You must be a logged-in exclusive member to view this reply.

  11. You must be a logged-in exclusive member to view this reply.

  12. hi justin,
    I did as you said but i get the following error:

    Catchable fatal error: Object of class WP_Error could not be converted to string in /mounted-storage/home17b/sub003/sc19060-WKEE/kokkekniven.com/wp-content/themes/leviathan/functions.php on line 143
  13. You must be a logged-in exclusive member to view this reply.

  14. Hi again jutin.

    Now the following error moved a line:

    Catchable fatal error: Object of class WP_Error could not be converted to string in /kokkekniven.com/wp-content/themes/leviathan/functions.php on line 144

    this is the whole functions.php from leviathan:

    <?php
    
    /**
     * This is your child theme's functions.php file.
     * You should make edits and add additional code above this point.
     * Only change the functions below if you know what you're doing.
     */
    
    /********************************************************/
    
    /**
     * For localization
     */
    load_theme_textdomain( 'leviathan', get_stylesheet_directory() );
    
    /**
     * Add theme-specific actions
     */
    add_action( 'hybrid_head', 'leviathan_remove_actions' );
    add_action( 'hybrid_after_header', 'hybrid_breadcrumb', 11 );
    
    add_action( 'hybrid_after_single', 'leviathan_author_box' );
    
    /**
     * Add theme-specific filters
     */
    add_filter( 'wp_page_menu_args', 'leviathan_page_menu_args' );
    add_filter( 'wp_page_menu', 'leviathan_subscribe' );
    
    /**
     * Remove actions from the parent theme
     * Removes breadcrumb (placed elsewhere)
     * Removes Secondary widgets (placed elsewhere)
     *
     * @since 0.1
     */
    function leviathan_remove_actions() {
    	remove_action( 'hybrid_before_content', 'hybrid_breadcrumb' );
    }
    
    /**
     * Page menu
     * Add/remove arguments for your page menu
     *
     * @since 0.1.2
     */
    function leviathan_page_menu_args( $args ) {
    	$args['depth'] = 4;
    	return $args;
    }
    
    /**
     * Adds a feed link to the page navigation
     *
     * @since 0.1
     */
    function leviathan_subscribe( $menu ) {
    
    	$feed = '<li class="feed-url"><a href="' . get_bloginfo( 'rss2_url' ) . '" title="' . __('Subscribe to the feed', 'leviathan') . '">' . __('Subscribe', 'leviathan') . '</a></li>';
    
    	$menu = str_replace( '</ul></div>', $feed . '</ul></div>', $menu );
    	return $menu;
    }
    
    add_filter('wp_page_menu', 'custom_page_nav');
    
    function custom_page_nav($menu) {
    	$menu = false;
    
    	$menu = '<div id="page-nav"><ul>';
    	$menu .= '<li><a href="http://www.kokkekniven.com" title="Example">Forsiden</a></li>';
    	$menu .= wp_list_pages('title_li=&depth=3&echo=0&include=133,90,60,495,2,154');
    	$menu .= '</ul></div>';
    
    	return $menu;
    }
    
    /**
     * Shows an author description after the post
     * Only shows on single post
     *
     * @since 0.1
     */
    function leviathan_author_box() {
    	global $hybrid_settings;
    ?>
    	<!--<div class="author-profile vcard">
    		<?php echo get_avatar( get_the_author_email(), '96', $hybrid_settings['default_avatar'] ); ?>
    		<h4 class="author-name fn n"><?php the_author_posts_link(); ?></h4>
    		<p class="author-description author-bio">
    			<?php the_author_description(); ?>
    		</p>
    	</div>-->
    	<?php
    }
    add_action( 'init', 'create_my_custom_tabs' );
    
    function create_my_custom_tabs() {
    	register_hybrid_tab( 'custom_1', array( 'label' => 'Nyhedsbrev', 'callback' => 'nyhedsbrev_function' ) );
    
    	register_hybrid_tab( 'basketball', array( 'label' => 'Twitter', 'callback' => 'twitter_scores' ) );
    }
    function nyhedsbrev_function() {
    	echo '<form action="http://www.kokkekniven.com/nyhedsbrev/" method="post">
    		<h3>Kokkeknivens Nyhedsbrev</h3>
    		<p>Nyhedsbrevet indeholder opskrifter, nyttige links, tips og nyheder fra og om Kokkekniven.com</p>
    <p>Nyhedsbrevet udsendes ca. 2-6 gange &aring;rligt og er 100% spamfrit.</p>
    <p>
    <label>Dit navn:</label><br />
    <input type="text" name="nn" /></p>
    <p>
    <label>Din email:</label><br />
    <input type="text" name="ne" /></p>
    
    <p><input type="submit" class="button" value="Tilmeld" /></p>
    <p><input type="hidden" name="na" value="s" /></p>
    </form>';
    }
    function twitter_scores() { ?>
    
    	<a href="https://twitter.com/madopskrifter"><img src="http://www.kokkekniven.com/wp-content/uploads/twitter.png" alt="Madopskrifter p&aring; twitter" title="Madopskrifter p&aring; Twitter" /></a>
    	<a href="http://www.kokkekniven.com/feed/"><img src="http://www.kokkekniven.com/wp-content/uploads/fees.png" alt="Opskrifter Rss for kokkekniven" title="Opskrifter Rss for Kokkekniven" /></a>
    <?php }
    ?>
    <?php
    add_filter( 'wp_title', 'my_title', 11 );
    function my_title( $title ) {
    	if ( !is_home() )
    		$title .= ': ' . get_bloginfo( 'name' );
    	return $title;
    }
    ?>
    <?php
    add_action( 'hybrid_after_entry', 'my_extra_metadata' );
    
    function my_extra_metadata() {
    global $post;
    	if ( !is_single() )
    		return false;
    
    	if ( in_category( '1' ) || has_tag( '3' ) ) {
    
    		echo '<div class="tagsleft">';
    			echo get_the_term_list( $post->ID, 'ingredienser', '<strong>Ingredienser:</strong><p> ', ', ', '</p>' );
    			echo get_the_term_list( $post->ID, 'type', '<strong>Type ret:</strong><p> ', ', ', '</p>' );
    		echo '</div>';
    
    		echo '<div class="tagsright">';
    			echo get_the_term_list( $post->ID, 'oprindelse', '<strong>Oprindelse:</strong><p> ', ', ', '</p>' );
    			echo get_the_term_list( $post->ID, 'season', '<strong>S&aelig;son:</strong><p> ', ', ', '</p>' );
    		echo '</div>';
    
    		echo '<strong>Giv opskriften en karakter</strong>';
    		if ( function_exists( 'the_ratings' ) )
    			the_ratings();
    		echo '</div>';
    	}
    }?>
  15. You must be a logged-in exclusive member to view this reply.

  16. Ahaa..ok, so i must admit im a bit confused here, or maybe its just early in the morning for me.

    I did have the taxonomies in question, but they are gone from the admin panel, after i removed the old code from functions.php - did i do wrong there?

  17. You must be a logged-in exclusive member to view this reply.

  18. Ok - then it WAS to early for me to start editing.
    Thank you so much justin.

  19. Its working like a charm justin and im very thankfull for that. if you look at the first post on my site, its a recipe for steamed cod and on the single entry the taxonomies are working, but the sidebar is moved all down beneath the post instead of being a sidebar.

    The sidebar works perfect on all other posts NOT being category ID=1

    Any ideas?

  20. You must be a logged-in exclusive member to view this reply.

  21. Sorry Justin, its the primary sidebar that looks wierd on single posts

  22. You must be a logged-in exclusive member to view this reply.

  23. You must be a logged-in exclusive member to view this reply.

  24. I guess i need to call out Britney Spears and make her sing "YES, he did it again" :-D

    All working now, thank you so much

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Core Framework (54 posts)
  • Hybrid Theme (22,711 posts)
  • Bliss Theme (255 posts)
  • Options Theme (10,362 posts)
  • Visionary Theme (767 posts)
  • WordPress (144 posts)
  • WordPress Plugins (2,146 posts)
  • bbPress Themes (308 posts)
  • General Discussion (5,572 posts)
  • Critical Theme (0 posts)
  • Hybrid News Theme (132 posts)
  • Hybrid Original Theme (26 posts)
  • Leviathan Theme (16 posts)
  • Life Collage Theme (9 posts)
  • Old School Theme (3 posts)
  • Outline Theme (108 posts)
  • Skeleton Theme (40 posts)
  • Structure Theme (2,768 posts)
  • Members Plugin (2 posts)
  • Cleaner Gallery Plugin (14 posts)
  • Get the Image Plugin (3 posts)
  • Message Board Plugin (0 posts)
  • Widgets Reloaded Plugin (0 posts)
  • Breadcrumb Trail Plugin (0 posts)
  • Query Posts Plugin (80 posts)
  • Hybrid Hook Plugin (7 posts)
  • Hybrid Hook Widgets Plugin (0 posts)
  • Hybrid Tabs (5 posts)