Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mike Martel

    (@mike_cowobo)

    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_tiles and pass it either: a query, a WP_Query object 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 );

    $opts is an array of options, the same as for the shortcode.

    Cheers,
    Mike

    Ps. 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 their Network_Query into WP Tiles. That would even enable pagination. Let me know if you are thinking of going down this route!

    Thread Starter Paul Barthmaier (pbrocks)

    (@pbarthmaier)

    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,
    Paul

    Thread Starter Paul Barthmaier (pbrocks)

    (@pbarthmaier)

    Hi 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?

    Plugin Author Mike Martel

    (@mike_cowobo)

    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,
    Mike

    Thread Starter Paul Barthmaier (pbrocks)

    (@pbarthmaier)

    The errors I get are:
    Notice: Trying to get property of non-object in /home/content/plugins/wp-tiles/src/WPTiles/WPTiles.php on line 723

    in 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 438

    Plugin Author Mike Martel

    (@mike_cowobo)

    Hi Paul,

    I haven’t tried using Post Indexer with WP Tiles yet myself, but I just verified that a Network_Query should definitely return an array of posts, so something is going wrong there. Can you check using var_dump or debugger what the contents of $posts is around line 185 if wp-tiles/src/WPTiles/WPTiles.php?

    Cheers,
    Mike

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying Network posts’ is closed to new replies.