Tạo mã QR cho liên kết bài viết của website

Sử dụng mã dưới đây chèn vào file functions.php của theme đang dùng thì ở cuối bất kỳ bài viết nào của bạn, cũng sẽ hiển thị một mã QR có thể chia sẻ nhanh hoặc quét nhanh bằng điện thoại =))

function maqr($content) {
if(is_singular()) {
ob_start();
?>
<div style="text-align:center">
<img src="https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=<?php the_permalink(); ?>" alt="QR: <?php the_title(); ?>"/>
</div>
<?php
$hienqr = ob_get_clean();
return $content . $hienqr;
} else {
return $content;
}
}
add_filter( 'the_content', 'maqr');

Có thể dùng 1 trong 2 nguồn tạo

<img src="http://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<?php the_permalink(); ?>" />

<img src="https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=<?php the_permalink(); ?>" />

Nguồn: caodem.com

Mới hơn Cũ hơn