davidmaxwaterman
Forum Replies Created
-
Forum: Hacks
In reply to: hacking tags cloud to only show terms assigned to this project.I should note that I am using an older version of php and so array_column wasn’t available, which would have made the code quite a bit simpler.
Also note I pass an array of my custom taxonomies into get_terms. I guess there’s a way to not have to hard-code those…I manually registered them elsewhere in the code.
Forum: Hacks
In reply to: hacking tags cloud to only show terms assigned to this project.OK, I made it work, so I’m recording my solution for prosperity. Here’s the diff :
diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index e48cc01..e72268c 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -1241,6 +1241,13 @@ class WP_Widget_Tag_Cloud extends WP_Widget { echo $before_title . $title . $after_title; echo '<div class="tagcloud">'; + // get terms for this taxonomy + $termsInThisTaxonomy=wp_get_object_terms(array(get_the_ID()), array($current_taxonomy)); + $include_terms = array(); + foreach ($termsInThisTaxonomy as $term) { + array_push($include_terms, $term->{'term_id'}); + } + /** * Filter the taxonomy used in the Tag Cloud widget. * @@ -1251,9 +1258,31 @@ class WP_Widget_Tag_Cloud extends WP_Widget { * * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'. */ - wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( - 'taxonomy' => $current_taxonomy - ) ) ); + if (count($include_terms)==0) { + // including no terms so exclude all terms + $args = array( + 'project_collection', + 'project_market_segment', + 'project_platform', + 'project_phase', + 'project_tag', + ); + $all_terms = get_terms( $args ); + + $exclude_terms = array(); + foreach ($all_terms as $term) { + array_push($exclude_terms, $term->{'term_id'}); + } + wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( + 'taxonomy' => $current_taxonomy, + 'exclude' => $exclude_terms + ) ) ); + } else { + wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( + 'taxonomy' => $current_taxonomy, + 'include' => $include_terms + ) ) ); + } echo "</div>\n"; echo $after_widget; @@ -1410,3 +1439,4 @@ function wp_widgets_init() { } add_action('init', 'wp_widgets_init', 1); +
It does what I want it to, so I’m happy, but, as I mention, I’m no wordpress expert and the above is quite likely a ‘hack’ in this context (ie there is a ‘proper way’). Comments welcome.
Max.
Forum: Hacks
In reply to: projects disappeared from all pageok, thanks…a step in the right direction, I think ??
Forum: Plugins
In reply to: [JSON API] JSON API Installation – No FTPIINM, the accepted procedure in this case is to copy the zip file into the wp-content/plugins/ directory and unzip it there (actually, I guess there’ no need to keep the zip file there, or at all).
The plugin should then appear in the list of plugins in the admin page where you can activate it/etc.