• Resolved caratage

    (@caratage)


    Loving the plugin and using it regularly. But just now a ran into a problem and I seem not to find the solution. Probably it’s very easy.

    I wrote a function in functions.php that allows me to display connected staff on different pages. Sometimes I need to display all or only one connection and there will be an offset to display the first connection differently:

    function show_connected_staff($offset, $numberposts) {
    	// Find connected posts
    	$args = array(
    		'connected_type' => 'staff_to_pages',
    		'connected_items' => get_queried_object(),
    		'nopaging' => true,
    		'suppress_filters' => true,
    		'connected_query' => array(
    			'offset' => $offset,
    			'numberposts' => $numberposts,
    		),
    	);
    	$persons = get_posts($args);
    	// Display connected posts
    	if ($persons) {
    		foreach($persons as $person) {
    			echo $person->post_title;
    		} // end foreach
    	} // end if
    } // end show_connected_staff

    Connections are set up properly, I can see all the data properly. Only problem is that the arguments are not passed to the function.

    So calling <?php show_connected_staff(1, 1); ?> or <?php show_connected_staff(0, 999); ?> in my theme will always display all connected items regardless of value of the arguments.

    Suggestions?

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter caratage

    (@caratage)

    OK, go figure: https://github.com/scribu/wp-posts-to-posts/wiki/Query-vars.

    Seems like native WordPress query variables do not work on connected_items.

    Thought again and found some other solution to my problem.
    Thanks anyway Scribu for the excellent plugin.

    Plugin Author scribu

    (@scribu)

    Seems like native WordPress query variables do not work on connected_query.

    Yes, they do, except for the ones related to pagination, since they don’t make sense there.

    You probably wanted to put them outside the ‘connected_query’ anyway.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with 'offset' and 'numberposts' while using get_posts() ?’ is closed to new replies.