Plugin aint working, what am I doing wrong
-
Hi,
Welltried to make a plugin, but it aint working, why not?
Plugin code:
<?php
function get_portal_topics () {
global $bbdb;
return $bbdb->query("SELECT * FROM $bbdb->topics WHERE forum_id = 1 ORDER BY topic_time DESC LIMIT 0,10");
}
?>
This has to give a list I need, but turning it into my template it get this error:
Warning: Invalid argument supplied for foreach() in /bbpress/bb-templates/portal-page.php on line 33
Template code:
<?php $portal_topics = get_portal_topics() ?>
<?php foreach($portal_topics as $topic) :
$portal_topic_posts = get_thread( $topic->topic_id); ?>
<h1><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></h1>
<?php printf(__('%1$s - <a href="%2$s">%3$s</a>'), get_topic_time(), get_user_profile_link($topic->topic_poster), get_topic_author()) ?><br/>
<?php echo $portal_topic_posts[0]->post_text; ?>
<div align="right"><?php printf(__('<a href="%1$s">Comments (%2$s)</a>'), get_topic_last_post_link(), get_topic_posts()) ?></div><br/>
<?php endforeach; ?>
Or my plugin is all wrong, or how I call it…. or both
Thx
- You must be logged in to reply to this topic.