我正在制作一个插件在每个页面的右下角添加图像。 Followin是功能正确的代码,并添加图像作为内容。wp_footer挂钩不工作
add_filter('the_content', 'scroll_to_top_data');
,但我想它在右下角页脚,我试过之后添加:
add_action('wp_footer', 'scroll_to_top_data');
也没有显示错误,这是没有在任何地方显示图像。我使用二十五个主题,但当然我希望这个插件可以在wordpress的所有主题上使用。请指导我为什么不能使用wp_footer钩子,并且如何在页脚之后放置它?下面是scroll_to_top_data功能
function scroll_to_top_data($content = NULL) {
$post_id = get_the_ID();
global $wpdb;
$table = $wpdb->prefix . 'scroll';
$myrows = $wpdb->get_results("SELECT * FROM $table WHERE id = 1");
$beforeafter = $myrows[0]->beforeafter;
$where_like = $myrows[0]->where_like;
$status = $myrows[0]->status;
$image = $myrows[0]->image;
$action = $myrows[0]->action;
$color = $myrows[0]->color;
$display = $myrows[0]->display;
$except_ids = $myrows[0]->except_ids;
$url = $myrows[0]->url;
$width = $myrows[0]->width;
$position = $myrows[0]->position;
$str = $image;
if ($status != 0) {
$scrollImage = '<img src="' . $image . '"';
return $content . $scrollImage;
} else {
return $content;
}
}
什么是'scroll_to_top_data'功能是什么样子? –
#Jesse我已经更新了我的问题,请检查。谢谢! –