• Hi,

    As a WP and php beginner it took me a while to uncover these bugs in your sample code:

    1.

    'posts_per_page' => 5

    misses the comma at the end

    2. don’t ask me why but rpt_get_object_relation() returns boolean 1 when there are no related posts. That makes this line (and more down the line) fail because it passes the check when it shouldn’t:

    if ( count($related_pages_ids) >= 1 ) {

    I fixed it by changing it to:

    if ( is_array($related_works_ids) ) {

    Hope this saves someone a couple of hours of hair pulling!

    Best, Dieter

    http://wordpress.org/extend/plugins/relation-post-types/

Viewing 1 replies (of 1 total)
  • I simplifed the display function to make it works correctly with use of get_the_ID and wp_list_pages functions:

    $related_pages_ids = rpt_get_object_relation(get_the_ID(), 'page');
    if ( is_array($related_pages_ids) ) {
    	echo '<ul>';
    	$liste_id = implode(",", $related_pages_ids);
    	wp_list_pages('include='.$liste_id.'&title_li=<h2>' . __("Related pages") . '</h2>' );
    	echo '</ul>';
    }
Viewing 1 replies (of 1 total)

The topic ‘2 bugs in the example’ is closed to new replies.