Categories
WordPress

Sitewide tags pages for WordPress MU

For WordPress MU only. My latest plugin is the sitewide tags pages plugin.

This is the initial release of a plugin that creates a set of pages like the WordPress.com Hot Topics pages. It’s a lot more simplistic, but by feeding posts into one blog it also creates a sitewide feed of all posts plus feeds of any tags and categories too.


Sitewide Tags Options

WordPress MU is a multi blog version of WordPress that runs on WordPress.com. If you use the regular version of WordPress this plugin is not for you and you can ignore this post.

PS. In other MU news. Raanan has a new post on the Publisher Blog about Nationen! blog, a new Danish blog site based on WordPress MU that looks rather nice!
The site was developed by Incsub who are also the guys behind wpmu.org where you’ll probably find all sorts of useful nuggets of MU goodness on a regular basis!

Comments

comments

"Sitewide tags pages for WordPress MU", 5 out of 5 based on 1 ratings.

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

139 replies on “Sitewide tags pages for WordPress MU”

Hi Donncha,

I love the plugin and I am requesting a little help.

I am looking for a way to show comments too. Also, I am looking for a way to only make selected blogs (subdomain blogs) to become global. So, new blogs that are created are not global. Only ones that I assign become global.

Justin – you mean show comment numbers next to the post title? Clicking on the title brings you to the original blog so there’s no need to display the actual comments.

Should be easy enough to only show posts from certain blogs with a blog action on the wpmu-blogs.php page.

[…] Some cute code bits include the login form, full support and integration for our MU avatars plugin, some really cute css / design stuff, the on page RSS tabber (controlled by the theme options) and we’ll be releasing shortly plugins to allow you to manage a list of recently updated blogs (with avatars) just like our ‘Supporters’ section and also, possibly, some of our global tagging stuff (although Donncha’s MU tags should work just as well!) […]

Some permalink issues in my non-vhost set-up:

Set-up:
non-vhost(http://sub.domain.org/)
My $tags_blog_id is 260.(http://sub.domain.org/tags/)

Blog 1 Permalinks are set: http://sub.domain.org/blog/%year%/%monthnum%/%day%/%postname%/

In the sidebar of Blog 1 I have:
switch_to_blog($tags_blog_id);
wp_tag_cloud();
restore_current_blog();

Issue:
All links in the tagcloud go 404 because they have these permalinks
http://sub.domain.org/tags/blog/tag/
but should be
http://sub.domain.org/tags/tag/

Workaround:
Blog 1 Permalinks are off: http://sub.domain.org/?p=123
An the sidebar tag_cloud links become http://sub.domain.org/tags/?tag=blogging-tips which work fine

However:
With permalinks off on blog 1, when saving a page(p=123) on blog 1, the tags blog wp_$tags_blog_id_postmeta–>post_id for that page is set to 0(but should be 123). Every save/update adds another row with post_id 0.

So that Custom fields( edit-form-advanced) show a growing list of custom fields with key “permalink” and value “http://sub.domain.org/?p=123” when writing a new post at the tags blog.

Phew. Thanks for letting me get that off my chest.

Ability to display custom fields (images especially) would be very nice and useful. Thanks for the great plugin. Also, I’m very happy to see that Thomas (few posts above) got more involved in WPMU. He’s a great guy and a great programmer… well, that’s my personal opinion:)

Cheers

I have a problem after acitivation this plugin to aggregate all the new post in the main blog. Since the activation my rss-feeds don’t work any more.
I get an XML-Error.
I have to add that I use for the generation of a sidewide feed the plugin WMPU Feed.
But the strange thing is that the rss-feed of each blog don’t work either.
When I click the rss button of the browser a get only the option to download the xml file of the rss feed.
I would be really grateful for any hint.

Elisabeth

I solved the problem and I have to apoligize.
The problem was caused by an other plugin which I installed yesterday.

You can delete this an my fist comment.
Thank you very much.

A great plugin!

Elisabeth

Thanks Donncha for the great plugin. But I have a small issue. When I post from home page of blog with Prologue theme (Twitter like theme), it displays following error:
“Fatal error: Call to undefined function wp_insert_category() in /home/myname/public_html/wp-content/mu-plugins/sitewide-tags.php on line 148”
I think reason is: on home page of Prologue theme, we insert only tags, not categories. Please advise me what should I do.

Thank you.

tulgaa – that’s because wp_insert_category() is defined in wp-admin/includes/taxonomy.php which isn’t loaded when you’re on the blog. Not sure how to get around that.

Hey Donncha,

Like tulgaa, I am getting the following error:

Fatal error: Call to undefined function wp_insert_category() in …/wp-content/mu-plugins/sitewide-tags.php on line 148

I am actually using FeedWordPress to syndicate Sitewide tags out to different class blogs. Seems like on a number of occasions I get this error when using FeedWordPress. Am I writing the exchange above correctly? Is this a theme issue? Is there anyway to modify or comment out this code, reason being is when FeedWordPress grabs a new post from a sitewide tag feed, it gets this message and kinda messes with the settings of the FeedWordPress plugin, making the post permalink remain on the course site rather than linking back to the original blog.

I know this is long winded, just want to try and figure this nut out.

Donncha,

I’m getting the same error as tulgaa above.

Fatal error: Call to undefined function wp_insert_category() in /home/umwblogs/public_html/wp-content/mu-plugins/sitewide-tags.php on line 148

Mine happens when I am using a plugin called feedWordpress to syndicate sitewide posts tagged uniquely intto course blogs. What happens is when the feedWordPress plugin pulls in this sitewide tag feed, it throws this error, and the actually feedWordPress plugin hiccups and changes the settings from having the permalink point to the original blog, to have it point to within the course blog.

So is this an issue that can;t be worked around? Is their a way to comment out the insert_category code?

Just drawing at straws here,.

Thanks

The plugin could either include whatever wp-admin include file is required, or just forego the categories. I suspect that including the right include file won’t be easy but it’s the right thing to do.

everything work fine except every time i save change in site admin -> option, it’s always generate new blog,

for example

when first time i instal it generate blog name tags(i change nothing in sitewide-tags configuration) with blog id “2” when i come again to this section and do samthing and save change it generate new blog using same name but different id ( blog name tags id 3 )

thanks for your time

Hey all,

First off Donncha, great plugin and it will be very useful. Secondly I was experiencing the same issue with the wp-content/mu-plugins/sitewide-tags.php on line 120/148 error, when using a prologue theme, and fixed it for the moment by simply adding the taxonomy.php code into the Prologue function.php file.

After doing so she fired right up and the post are appearing as well as the tags.

Is there any dangers or concerns with this method anyone can think of?

George

Sorry guys, I may have jumped the gun on that fix, it doesn’t work very well, as the second you enter the admin of the blog, it states that it can’t redeclare category_exists() (previously declared.

I am still trying to find a way around it. Any ideas? I have narrowed it down to a specific Prologue theme issue in my case.

George

No FeedWordPress plugin here, but by reading the other comments, Donncha is dead on with why it appears as it relates to either the presence of the function(s) in the taxonomy.php file.

Just need to make them play nice together. Does anyone know of a way to detect the existence of each case and prevent the other from overstepping each other?

Just a thought I am working on.

Okay, I followed up on a recommendation Donncha provided regarding foregoing the categories altogether. Considering that there are really no uses for categories in my opinion with the Prologue or similar themes, I commented out lines 118-122 in the sitewide-tags.php file. Everything seems to work great!

Not sure how to get around the FeedWordPress issue as I do not have it installed at the moment, sorry. I hope this puts you a step further.

Might it be possible to add a configuration option that we can toggle to support this in future versions if using a Prologue type theme?

Another option or default check would be in support of subdomain or /directory installations so to prevent duplicate tag blog site being created.

George – the best way of fixing this is by including the taxonomy.php file in the plugin if wp_insert_category doesn’t exist. That may work, but I don’t know if it will be missing any important constants or variables set up by the wp-admin init files.

@MuSnake

you said: Using the Simple Tags plugin’s TagCloud shortcode, I was able to display the global tags on a page, then set that page to be the frontpage of the tags blog…

Can you provide an example of how you do that please? I know this plugin was made to facilitate such use, but I can’t seem to graps how to show tags from tags.domain.com on the main blog aka domain.com 🙁

Is it possible to retrieve older posts in the tag blog?
The plugin only gets posts that were written after the installation.
Thank you very much for your help.

I have a very odd problem. I’ve just done a clean install of WP MU 2.6.1. I have the main blog plus one “user” blog. Both are pretty “clean” (read: no posts except for the initial defaults).

No tags or categories exist in the system.

When I add a new post or page to either blog, without giving it a tag, it takes “forever” after publishing. I either wait until timeout, or stop before it gets there, and look at the number of posts or pages. Instead of 2, there are hundreds, all copies of the one I had just created.

Tried this with no other plugin installed, tried it both with this plugin in the “real” plugins (my mistake at first) then in the mu-plugins. Same behavior…

Thoughts?

Regarding the trailing slash bug, wouldn’t it be better to do the following in the non-vhosts update section (lines 72/73, or there-abouts in the stable release .2):

$path = $current_site->path . $tags_blog;
$path = trailingslashit($path);

I’ve tested it on a non-vhosts install and it fixed the issue for me, and seems like the safer approach, since you don’t know what a user is going to put in that text field.

So I’m now running WPMU 2.6 with MULTIPLE top-level domain blogs (managed by Multisite Manager through unique site id’s) and sub domains hanging off these various top-level ones.

I understand that our configuration is probably well away from what most people are doing with MU, but to be honest our set up is working great! However, I’m wondering whether the ‘Sitewide Tags’ plugin was only ever designed to work for a single top-level domain with multiple sub blogs?

The reason I’m asking is we’ve tried to get your plug in to work several times under this configuration but to no avail (also in MU 1.5). It will either/or aggregate ALL posts across all domains, and/or create thousands of duplicate empty posts in one of the existing blogs (no rhyme nor reason as to which subdomain or top-level domain blog it chooses). This is obviously most disturbing 😉

Are we being too ambitious with your plugin in our current set up?

Is it possible to have the sitewide posts aggregate in the “root” blog as opposed to tags, or another “sub” blog?

/wordpress/
as opposed to
/wordpress/tags/
or
/wordpress/anotherblog/

@Donncha, I tried to do this, but for some reason it still could not redeclare. I am not sure if I tried to detect if wp_insert_category function existed or not. I’ll take another stab at it and share the findings.

George

Question for anyone / (Donncha). How/where would you change the the permalink for the author’s name for example on a post fed to the repository blog?

I want the ability to store everyone’s post as public, but when clicking any permalink, it is actually the link to the user’s blog versus the standard author page. I assume this must happen both at the sitewide tag update level as well as the theme level, but not sure where to pass or store the meta data, and what linking structure to use in the theme.

George

Found a working solution to point each post back to the author’s blog from the Tags Blog post. Not too elegant, but it did not require any changes to the core of the plugin.

<a href=”http://rootsite.domain/”> at: on

George

Hi Donccha, awesome plugin for the wpmu, works great. Speedy too! I found a bug in the plugin that I can’t seem to workaround. When it’s still set to unpublished, it saves the GUID numbered link instead of the permalink (which doesn’t exist yet) On TAGS blog and that’s fine. When I go to publish and use a new URL, it saves it again as another permalink entry in the TAGS blog postmeta table. When called up, it just uses the previous permalink instead of the latest entry.

Is there any way for the plugin to find the entry based on wp_#_post/guid, then edit the wp_#_postmeta/permalink instead of writing a new permalink entry? Content output updates, but the permalink uses the old ones. Thanks!!

@Dsader
I was having a similar problem, so seeing your comment really helped. (All links in tagcloud were going to 404 page, couldn’t figure out why… changing theme didn’t help, thought they worked before and couldn’t remember when they broke, etc… Changing permalinks from “Day and Name” to “Default” fixed it.)

@mike:
Donncha released today a new version. The new version has this feature (read also my first comment here, please)
@creativeherb and @Esther:
Version 0.3.1 should fix this too, because I have had the same problem at the development time. I changed the code for permalinks in trunk some weeks ago and now it works fine for me. The changed code comes to public with Donnchas release 0.3.1 today. If I’m goes wrong, please let us know.
Finally: the link to version 0.3.1 🙂

Cheers, Thomas

@Thomas: the new version (0.3.1) seemed to have worked well! I will do further testing and if it breaks I’ll post again. However because I already had posts, I had to clear the wp_#_postmeta and wp_#_posts and republished the articles to have the proper permalinks kick in. (since the GUID links were already in the tables, using the broken older version of the plugin)

I also had to clear the RSS cache from wp_sitemeta because it kept using some of the older cache.
Actually that’s another annoying thing, don’t know why wpmu uses old RSS cache sometimes… I can imagine that it would keep building up, because I had to delete about 8-10sets of RSS cache from wp_sitemeta.

Creativeb – the build up of rss cached items is a WordPress issue. In Tweet Tweet I had to manually cleanup those cached files because my options table was filling up so much!

Hi there! I’ve installed the plug-in, with no hassles – but nothing seems to be happening on the tags blog (tags.artcider.com) – what should I expect?

Regards.

Donncha: ya the rss cache issue really is a problem because it seems to be so random. Do you think it will be fixed someday soon or is it actually a really difficult issue to fix?

Cas: if you already have posts just resave each post once by clicking “save”, no need to republish. If you have a ton of posts tho then you might find to find a more elegant solution. The plugin works with posts from the time of the plugin installation.

Seems like there’s a problem with the postmeta saving. Every time a post is saved, duplicates are made, and the very first permalink meta_key is the direct one (for example: http://wisecracker.paidtoblog.com/?p=3). This can cause the permalinks to be returned incorrectly if a post has no revisions to it, as the last duplicate is always the one returned and contains the correct permalink.

hrrm. could it be i only have one post 😛 im still building the site, so i dont have much to write about..! ill try adding a few more posts and seeing if it works.

can anyone show me an example of what it should look like? is it like the tags on wordpress’ site (shown in the documentation for this plugin)??

regards!

anyone having any luck with copying over the metadata as well. I want to display thumbnails of the images in the posts, and I need the meta data for that. I tried inserting
$the_attachment_meta = get_post_meta( $post_id, '_wp_attachment_metadata' ); after line 157 but it just gives me an php error. does anyone know why? should I be passing it something other than the $post_id? or should I be using another function specifically for attachments such as get_attached_file()? Once I get the meta data in a url it will be easy to insert it again below. and I could even alter the admin to optionally turn this on and off. any help would be greatly appreciated.

So I’m now running WPMU 2.6 with MULTIPLE top-level domain blogs (managed by Multisite Manager through unique site id’s) and sub domains hanging off these various top-level ones.

I understand that our configuration is probably well away from what most people are doing with MU, but to be honest our set up is working great! However, I’m wondering whether the ‘Sitewide Tags’ plugin was only ever designed to work for a single top-level domain with multiple sub blogs?

The reason I’m asking is we’ve tried to get your plug in to work several times under this configuration but to no avail (also in MU 1.5). It will either/or aggregate ALL posts across all domains, and/or create thousands of duplicate empty posts in one of the existing blogs (no rhyme nor reason as to which subdomain or top-level domain blog it chooses). This is obviously most disturbing 😉

Are we being too ambitious with your plugin in our current set up?

Duncan – I guess so. I don’t like what the multisite plugin does as running blogs as different sites really isn’t the best way of doing it. Does the plugin try to create a tags blog on each of the sites?

Have you tried the domain mapping plugin?

If you must run multiple sites I would suggest you use multiple installs of WordPress MU rather than creating new records in wp_sites. ‘Course if you want to debug this problem and submit a patch I’d love to get that too and make it work better!

Leave a Reply to Ovidiu Cancel reply