WordPress.org

Ready to get started?Download WordPress

Forums

Better Tag Cloud
Multiple Taxonomies? (10 posts)

  1. GeneralReason
    Member
    Posted 1 year ago #

    How do you enter multiple Taxonomies in the Taxonomy field?

    http://wordpress.org/extend/plugins/nktagcloud/

  2. GeneralReason
    Member
    Posted 1 year ago #

    How do I edit the function..

    <?php $this->nktagcloud_input( __( 'Taxonomy', 'nktagcloud' ), 'taxonomy', 15, $instance['taxonomy'] ) ?>

    so that we may enter multiple Taxonomies in the cloud widget config?

  3. GeneralReason
    Member
    Posted 1 year ago #

    or is it rather editing the
    $taxonomy= $config['taxonomy'];

    relationship in page.php?

    Again my objective is to be able to simply enter multiple taxonomies into the taxonomy field from the cloud widget config. The field allows only one entry, with a default 'post_tag'

    I mean variable $taxonomy is defined as an a array right? But that wont allow the User to add multiple taxonomy strings for example say I wanted the cloud to display tags from three different taxonomies. How would you input this into the Taxonomy field? taxonomy1, taxonomy2, taxonomy3,? I have tried alot of logical combinations. You can only enter one!

    Pls help.

  4. Ov3rfly
    Member
    Posted 1 year ago #

    Took a quick look, $args['taxonomy'] is used as single string in the plugin for several WordPress-API calls which can only handle one taxonomy as a string, not as an array, e.g. get_the_terms() if $args['post_id'] or $args['single'] == 'Yes' are used and also in the main loop starting at line 214 at get_term_link() for every single tag.

    Seems like a quick "hack" is not possible. To use multiple taxonomies, a major rewrite of the whole main loop and also some more would be required.

  5. GeneralReason
    Member
    Posted 1 year ago #

    Thank you so much for the reply Ov3rfly. Really appreciated.

    So from what I'm gathering because several WP-APIs can only handle one taxonomy string, not as an array -this would mean we can't get an nktagcloud function to query for an array of tags? What loops would we actually need to be rewriting?

    I really couldn't believe I couldn't find any plugins that allow you to use a cloud tag with multiple taxonomies vs. just 1. Surely I am not the only one with this concern?

    "A major rewrite of the whole main loop and some more would be required"
    - Is there anyway I may please get assistance with this?

  6. Ov3rfly
    Member
    Posted 1 year ago #

    Since WordPress 3.1 the existing WordPress-API wp_tag_cloud() supports multiple taxonomies as an array, maybe that's why there are no such plugins.

    Example from http://codex.wordpress.org/Function_Reference/wp_tag_cloud

    <?php
      $args = array(
        'taxonomy'  => array('post_tag','category'),
       ); 
    
      wp_tag_cloud($args);
    ?>

    Maybe you don't even need "Better Tag Cloud" plugin for your purposes.

  7. Ov3rfly
    Member
    Posted 1 year ago #

    If you can "hardcode" your multiple taxonomies, you can add something like this e.g. to your sidebar.php in <ul class="xoxo"> block with WordPress 3.1+:

    <?php	// Customized tag cloud:
    	if ( function_exists('wp_tag_cloud') ) : ?>
    <li id="customized_tag_cloud" class="widget-container widget_tag_cloud"><h3 class="widget-title"><?php _e( 'Tags' ); ?></h3><div class="tagcloud"><?php
    		$args = array(
    			'taxonomy'  => array('post_tag', 'category'),
    			'largest' => 18
    		);
    		wp_tag_cloud($args);
    ?></div></li>
    <?php 	endif; // end customized tag cloud ?>

    This displays multiple taxonomies, the normal tags and the categories.

  8. Ov3rfly
    Member
    Posted 1 year ago #

    If you do not want to hardcode the complete wp_tag_cloud() call in sidebar, there is a second possibility without any changes to sidebar.php:

    1. Add a standard default WordPress tag cloud widget to your widget area, the Taxonomy setting does not matter, as it will be overwritten.
    2. Add the following code to your functions.php which overwrites the $args['taxonomy'] (and also other settings if you want) with new values:

    function ov3rfly_widget_tag_cloud_args( $args ) {
    	$args['taxonomy'] = array('post_tag', 'category');
    	$args['largest'] = 18;
    	return $args;
    }
    add_filter( 'widget_tag_cloud_args', 'ov3rfly_widget_tag_cloud_args' );

    Note: This change affects all tag clouds widgets within WordPress.

    Enough talking to myself now, that's it for multiple taxonomies here... ;-)

    If you need a complete widget where your taxonomies are configurable via a text-field in WordPress widget backend, let me know how I can directly get in touch with you.

  9. GeneralReason
    Member
    Posted 1 year ago #

    Hello Ov3rfly.

    Sorry for the late response.

    I got your messages. I've added you to my googletalk. Unless you have a more preferred instant messenger.

    Thanks

  10. Ov3rfly
    Member
    Posted 1 year ago #

    For interested readers, have added multiple taxonomies support to "Better Tag Cloud" now, if anybody else besides GeneralReason is interested, let me know here...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.