Thanks Ron, I will try it out now.
Another ‘tiny’ issue that I’m wrestling with is integrating the wootumblog plugin with STW. The use case is as follows;
The wootumblog plugin – http://www.woothemes.com/support/wootumblog/ – uses a custom taxonomy and is working fine on both my main blog and user blogs – but the taxonomy type (i.e. photo, video, quote) is not making it through the STW filter when displayed on the homepage of our main blog. The posts get through, but the custom type is not recognised and therefore defaults to ‘article’.
I’m still getting my head around the architecture of custom post types – any suggestions?
See this post: http://wpmututorials.com/plugins/sitewide-tags-update/
We have quite a few posts with info on SWT. You should be able to find them all by using our search for “sitewide tags’.
Thanks Ron.
As I’ve been looking through the sitewide-tags.php file I noticed the following line of code which looks like it may be a typo..
LINE 552: add_filter( ‘sitewide_tags_allowed_post_types’, ‘sitewide_tages_pages_filter’ );
Shouldn’t the filter be ‘sitewide_tags_pages_filter’ ?
Nice catch.
That’s what the function is called, so changing just that line would give you an error.
I updated the dev version and removed the typo in the function name and changed the filter.
Ron, sorry to ask a really simple question but where do I add the filter in order to include the custom taxonomy within the SWT blog? I have worked with WP for years, but this is the first time I’ve used custom taxonomies.
Here’s the filter to be added:
add_filter( 'sitewide_tags_custom_taxonomies', array(&$this, 'tumblog') );
Do I add it in sitewide-tags.php within the sitewide_tags_post function? And I presume I should re-run ‘Populate Posts’?
I’ve checked to ensure it’s the correct taxonomy using <?php $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' ); echo $tumblog_list; ?>
So can see that the custom taxonomy exists in the source blog posts before being aggregated.
sorry to ask a really simple question but where do I add the filter in order to include the custom taxonomy within the SWT blog
If you’ve written a class then add the filter in the constructor of your class.
Thanks Ron, unfortunately I don’t actually know what you mean when you say
“If you’ve written a class then add the filter in the constructor of your class.”
I have not previously worked with constructors and classes.
If you get a moment to elaborate any further (i.e. put this section of code in this file) then it would be much appreciated, otherwise I’ll ask someone more experienced than me to translate.
Ron, this is the section of code that I am adding to my sub-sites’ functions.php file.
// Custom Taxonomy Tumblog Filter
add_action('pre_get_posts', 'woo_taxonomy_tumblog_filter' );
function woo_taxonomy_tumblog_filter( $query ) {
global $wp_query;
if ($query->is_home || $query->is_front_page) {
$query->set('tax_query', array( 'taxonomy' => 'tumblog' ));
$query->parse_query();
}
return $query;
}
add_filter( 'sitewide_tags_custom_taxonomies', 'woo_taxonomy_tumblog_filter' );
It doesn’t seem to work – i.e. the taxonomy type still doesn’t respond to a simple query on the main site.
Please let me know if I’m heading in the right direction – I’ve been trading emails with the wootumblog main developer (jeffikus) and once we’ve cracked it will share with the community how to recreate the function.
Please let me know if I’m heading in the right direction
No, that’s not the right direction. It looks like you are trying to alter the WP query on the main site by adding a filter to the sub site.
From http://wpmututorials.com/plugins/sitewide-tags-update/
Custom taxonomies use a similar filter
add_filter( ‘sitewide_tags_custom_taxonomies’, ‘my_swt_custom_tax_filter’ )
The filter passes an array formatted like array( ‘post_format’, ‘subject’ ).
That means what is passed to your filter is an array (not a WP Query object) and you add elements to that array:
function my_swt_custom_tax_filter( $taxonomies ) {
$taxonomies[] = 'tumblog';
return $taxonomies;
}
add_filter( 'sitewide_tags_custom_taxonomies', 'my_swt_custom_tax_filter' );
Your main site has to have a theme that supports the tumblog taxonomy.
Ron, thanks for clarifying that.
Both my sub site and main site use the same theme – a modified version of BP Default and the tumblog plugin is activated on the main site, whilst I have added its posting functionality within the functions.php in my sub sites.
So the tumblog functionality works perfectly in both main and sub-sites – the only problem is that the sub-site taxonomies are filtered out by the sitewide tags plugin and therefore when I display a list of posts from across the network, only those from the main site are recognised as tumblog posts.
So where do I place the above filter? In my main site’s functions.php or sub site? Or perhaps a plugin as I noted on Boone Gorges blog – http://teleogistic.net/2010/08/enabling-popularity-contest-for-wordpress-networkwide-use/comment-page-1/#comment-14150
Okay, I have created a plugin and then network activated it on the main site.
<?php
/*
Plugin Name: SWT Custom Taxonomy
Plugin URI: http://skiddnet.com
Description: Addition of new custom taxonomies to the wpmu sitewide tags plugin.
Version: 1.0
Author: CitizenSlide
Author URI: http://skiddnet.com
License: GPL2
*/
function my_swt_custom_tax_filter( $taxonomies ) {
$taxonomies[] = 'tumblog';
return $taxonomies;
}
add_filter( 'sitewide_tags_custom_taxonomies', 'my_swt_custom_tax_filter' );
?>
Still no sign of those taxonomies. Thanks for all your help (and patience) thus far, I’ll keep reading and searching for additional clues.
That won’t have any effect on existing posts. It will only apply to new ones.
I’ve tested it on both existing (after re-populating posts into the tag blog) and new posts and I’m still not seeing any effect.
Need to go live today, so unfortunately may have to unravel the sitewide functionality from the design.
I can appreciate how tedious it can be to try and solve one case, but what would be really useful is some real life examples. Most people just need to see and/or recreate a working scenario before we achieved that ‘Eureka’ moment with our own problems.
If you find the time in future, perhaps you could illustrate on wpmututorials how to adapt SWT to use custom posts types, custom taxonomies and custom fields. Perhaps then other developers could contribute their own solutions and we’d have a knowledge base for the less experienced developers to use. Just a thought.