Problem with 'offset' and 'numberposts' while using get_posts() ?
-
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?
- The topic ‘Problem with 'offset' and 'numberposts' while using get_posts() ?’ is closed to new replies.