如果您使用Google图表工具api,则无需插件。它非常简单,我有一个前不久编写的函数:
/*
* function to get QR code Image from google chart API
* @Params:
* $content - (string) the content to store inside the QR code (eg: url,address,string..)
* $size - (string) the size of the QR code image , must be in heightxwidth format(eg: 150x150 , 320x320)
* $ImgTag - (bool) if set to true the function will echo out the full img tag of QR code image ,
* if false then the function will return the image src (default = true)
*/
function get_QR_code($content = null,$size = null,$ImgTag = true){
if ($size == null){
$size = \'150x150\';
}
if ($ImgTag){
echo \'<img src="http://chart.apis.google.com/chart?cht=qr&chs=\'.$size.\'&choe=UTF-8&chld=H&chl=\'.$content .\'">\';
}else{
return \'http://chart.apis.google.com/chart?cht=qr&chs=\'.$size.\'&choe=UTF-8&chld=H&chl=\'.$content;
}
}
Usage:
<?php get_QR_code(\'Hello form Google API\'); ?>
这将为您提供:
所以一旦你在你的主题函数中有了这个函数。php文件您可以在模板中调用它,并将自定义字段值作为内容传递:
$qr_content = get_post_meta($post->ID,\'vendor_address_field_name\',true);
get_QR_code($qr_content);