Home Forums General Issues Reverse relationship – the_content Reply To: Reverse relationship – the_content

  • Hi renee, kylu –

    the reason this won’t work is that the_content and get_the_content are only meant to be used within ‘The Loop’ and therefore do not accept a post id parameter.

    my personal solution to this would be using WP_Query directly (rather than get_posts) to create a secondary loop, but within the context of your code above you can probably get around this through the use of setup_postdata as in the example here:

    and remember to call wp_reset_postdata after the fact.

    EDIT: as an afterthought… you should be able to access all post data directly from your $items array the same way you are accessing the id. the only problem is that this bypasses all content filters so you would have to apply them manually.

    something like:

    $content = apply_filters( 'the_content', $item->post_content );