我刚刚开始wordpress开发。我正在尝试创建一个简单的插件,用于显示表中db的结果。我可以做到这一点,但我对显示在管理页面顶部的插件有问题。我不知道为什么会这样。
我的插件功能:
add_action(\'init\',\'hello_world\');
function hello_world()
{
global $wpdb;
$query = "Select ID, post_title
From $wpdb->posts Limit 0, 10";
$results = $wpdb->get_results($query, ARRAY_A);
echo "<div class=\\"datagrid\\"><table>";
echo "<thead><tr><th>header</th><th>header</th><th>header</th><th>header</th></tr></thead>";
echo "<tfoot>
<tr>
<td colspan=\\"4\\">
<div id=\\"paging\\">
<ul>
<li>
<a href=\\"#\\"><span>Previous</span></a>
</li>
<li>
<a href=\\"#\\" class=\\"active\\"><span>1</span></a>
</li>
<li>
<a href=\\"#\\"><span>2</span></a>
</li>
<li>
<a href=\\"#\\"><span>3</span></a>
</li>
<li>
<a href=\\"#\\"><span>4</span></a>
</li>
<li>
<a href=\\"#\\"><span>5</span></a>
</li>
<li>
<a href=\\"#\\"><span>Next</span></a>
</li>
</ul>
</div>
</tr>
</tfoot>";
echo "<tbody>";
$i = 0;
while($i < 10)
{
foreach ($results as $item)
{
$postID = $item[\'ID\'];
$postTitle = $item[\'post_title\'];
echo "<tr class=\\"alt\\">";
echo "<td>" .$postID."</td>";
echo "<td>".$postTitle."</td>";
echo "</tr>";
$i++;
}
}
echo "</tbody>";
echo "</table></div>";
}
正在调用索引。php <?php
if(is_admin())
{
}
else
{
if(function_exists(\'hello_world\')) {
echo "<div>";
hello_world();
echo "</div>";
}
}
?>
我怎样才能防止它显示在管理部分?