Displaying Network posts
-
Hiya,
I love this plugin and would like to use this for a client. I’m wondering if it’s possible to display a network feed that is created by another plugin. That is, use the network feed to pull in posts from around the multisite network? Possible?
-
Hi Paul,
Thanks for your comment! If you use WP Tiles in a php template, you can feed any array of posts to it, so also the posts generated by your network feed plugin.
With the 1.0 beta version, in a template you can use
the_wp_tilesand pass it either: a query, aWP_Queryobject or an array of posts. So something like this should work:$posts = network_get_posts(); // Replace this with your plugin's function to get an array of posts the_wp_tiles( $posts, $opts );$optsis an array of options, the same as for the shortcode.Cheers,
MikePs. are you using Post Indexer by WPMU? I was just looking at the code, and they have a class that mimics
WP_Query. One could even make it so that you could pass theirNetwork_Queryinto WP Tiles. That would even enable pagination. Let me know if you are thinking of going down this route!Hi Mike,
Thanks so much for the reply. Yes, that is exactly the route I am going down. Your suggestion for implementing the Network query would be much appreciated!
Cheers,
PaulHi again,
To display network posts from the wpmudev plugins, you would used the ‘globalrecentposts’ short code. There is a constructor class created that looks like this:
class recentpostsshortcode { var $build = 1; var $db; function __construct() { global $wpdb; $this->db =& $wpdb; if($this->db->blogid == 1) { // Only add the feed for the main site add_action('init', array(&$this, 'initialise_recentpostsshortcode') ); } add_shortcode( 'globalrecentposts', array( &$this, 'display_recent_posts_shortcode') ); } function recentpostsshortcode() { $this->__construct(); } function initialise_recentpostsshortcode() { // In case we need it in future :) }What should I do to pass the network query into wp-tiles?
Hi Paul,
Cool, I have been itching to implement WP Tiles to aggregate MS posts for a while now, but haven’t had the occasion yet.
Last week I made WP Tiles work with object that look like WP_Query, and Network_Query should work. I haven’t had a chance to test yet, but when I do, I’ll revert back here. Let me know if you give it a whirl.
To get it to work, grab the latest version and use the
the_wp_tiles( $query, $opts )template with a network query.For example:
// Somewhere in a template file $query = new Network_Query( array( 'posts_per_page' => 10 ) ); $opts = array( 'pagination' => 'ajax' // Just because it would be really // cool if this worked out of the box :) ); the_wp_tiles( $query, $opts );Let me know if you have any luck with this! If this works, it might be a nice option to include as an add-on.
Cheers,
MikeThe errors I get are:
Notice: Trying to get property of non-object in /home/content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 723in several places
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 724
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 726
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 727
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 748
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 756
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 765
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 729
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 474
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 474
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 475
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 656
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 383
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 438
..content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 438Hi Paul,
I haven’t tried using Post Indexer with WP Tiles yet myself, but I just verified that a
Network_Queryshould definitely return an array of posts, so something is going wrong there. Can you check usingvar_dumpor debugger what the contents of$postsis around line 185 ifwp-tiles/src/WPTiles/WPTiles.php?Cheers,
Mike
The topic ‘Displaying Network posts’ is closed to new replies.