• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » How To Create QR CODE Image After Published New Article Wordpress

How To Create QR CODE Image After Published New Article WordPress

By Sigit Prasetya Nugroho ∙ July 20, 2016 ∙ PHP, Wordpress ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

Answering a question from one of my blog visitors , Asheesh. He asked, how to create a QR code image after doing a published content WordPress. I have tried to make the code in WordPress themes. Hopefully, can solve the problem.

With a WordPress action hook, namely publish_post, after doing publish a new article, WordPress will establish a QR code image and stored it in the folder on the theme.

To make the QR code generator process , you can read through my previous article How to Build QR Code Generator Site With PHP QR CODE library. I don’t understand what the goal he creates these script. But, just started following tutorials

How to create QR code image after do published an article on WordPress blog

  • Make sure you have downloaded the phpqrcode library.
  • Create a folder in your WordPress theme and name “qrcode“. Don’t forget to change the permissions of the folder be 777 or 755. In this example, I am using a Twenty Fifteen theme.
    Create New Folder On Your Theme How To Create QR CODE Image After Published New Article WordPress
  • Copy the  phpqrcode folder to qrcode folder.
    Copy The Phpqrcode Library On Qrcode Folder
  • Add the following code in the function.php in your WordPress theme

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function post_published_notification( $ID, $post ) {
    $permalink = get_permalink( $ID );
   include get_template_directory().'/qrcode/phpqrcode/qrlib.php';
define('EXAMPLE_TMP_SERVERPATH', get_template_directory().'/qrcode/');
define('EXAMPLE_TMP_URLRELPATH', get_template_directory().'/qrcode/');
$tempDir = EXAMPLE_TMP_SERVERPATH;  
$codeContents = $permalink;
$fileName = $post->post_title.'.png';
$pngAbsoluteFilePath = $tempDir.$fileName;
$urlRelativeFilePath = EXAMPLE_TMP_URLRELPATH.$fileName;
if (!file_exists($pngAbsoluteFilePath)) {
QRcode::png($codeContents, $pngAbsoluteFilePath);
}
}
add_action( 'publish_post', 'post_published_notification', 10, 2 );

Save it and please see the result by adding a new post. If you are successful. then it will get the results as shown below.

Related Articles :

  • How to Build QR Code Generator Site With PHP QR CODE library

Result How To Create QR CODE Image After Published New Article WordPress

Besides to show permalink on QR Code image, you can add additional information such as author, name,email, title with the following codes

1
2
3
4
    $author = $post->post_author; /* Post author ID. */
    $name = get_the_author_meta( 'display_name', $author );
    $email = get_the_author_meta( 'user_email', $author );
    $title = $post->post_title;

So my article about How To Create QR CODE Image After Published New Article WordPress. Hope useful

Another PHP Related Post :

  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com