Hey,
I'm having an odd problem with Semiologic's Terms2Posts plugin. I can only use the function inside the loop, even on single pages. What I'm trying to do is:
<?php if (is_single()) { ?>
<h3>Related Posts</h3>
<?php sem_terms2posts(); ?>
<?php } ?>
Except that's not returning anything. So I dove into the code and made the function return instead of echo.
Then, in my single.php template WITHIN the loop, I added <?php $related = sem_terms2posts(); ?>
Then I went back to sidebar.php and added global $related; echo $related;
And that works! Which seems strange to me. I tried declaring the global $post variable, but that turned up nothing from sem_terms2posts(). I know that's still available because print_r($post) prints the whole object with all its information intact.
I narrowed the problem down to:
if ( $terms && sizeof( $terms ) && function_exists('sem_search_posts') ) ... $terms is unavailable. So I dove into sem_extract_terms for a bit before giving up and posting here.
So, any ideas?