我正在製作一個插件在每個頁面的右下角添加圖像。 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我已經更新了我的問題,請檢查。謝謝! –