wpsmith / genesis-sandbox-featured-content-widget

Genesis Sandbox Featured Content Widget. Based on Nick Croft's Genesis Featured Widget Amplified for additional functionality which allows support for custom post types, taxonomies, and extends the flexibility of the widget via action hooks to allow the elements to be re-positioned or other elements to be added.
39 stars 21 forks source link

Enhancement request: Add ability to filter multisite blogs #29

Closed tomfinitely closed 1 year ago

tomfinitely commented 10 years ago

It would be great if there were a conditional that looked for multisite and gave the user the ability to set posts to be filtered by blog(s).

wpsmith commented 10 years ago

So, if the WordPress installation is a multisite setup and the plugin is installed on the primary site, you would like the widget to pull in posts from a particular blog?

Can you explain further?

tomfinitely commented 10 years ago

I just want a dropdown where I can choose a subsite and see what categories are under it, and choose a "remote category" as an option in the widget. So, if the plugin is installed on any given site (site D, for example) it should be able to pull posts at the least from any of the other blogs on the network (sites A, B, C, etc.) via a dropdown option in the widget.

Per my feedback to you via the WP Plugin repo, I was actually able to use switch_to_blog() to force GSFC to look for posts on the main site, blog 1, and output them on the homepage of blog 16.

The issue I encountered via interrupting the loop is that I'm unable to category filter via the widget's admin dropdowns, obviously because the widget is only switching to blog 1 when my additional code executes to render the front end. However, on a lark I attempted to create a "shadow" category structure on blog 16 that mimicked the category hierarchy on blog 1, and voila, GSFC brought in exactly the posts I wanted. Which was pretty cool... I got the technique from this plugin.

That said, it's a total kludge and not necessarily stable, and definitely not dynamic or user-manageable. I'm just wondering if you can somewhat easily get the widget backend to conditionally detect multisite, query the DB & supply a list of all subsites present in the install, and then once a subsite is chosen, provide the user the ability to select a category that resides on the chosen source site?

There's a plugin that manages to do this, but it's a lot more complex than GSFC and a bit crappy to set up.