Script is disabled WordPress: SHORTCODE with Database - Portal Integrators
Select Page

WordPress: SHORTCODE with Database

by

Not all the time developer needs to install plugins for them to get what they need especially in the database.

WordPress has so-called SHORTCODE which helped the user to do what he needs to do, through codes. SHORTCODE is a function wherein user can display or process something that he/she can use in pages or posts.

SHORTCODE became the best friend of a developer when it comes to WordPress so don’t forget this approach so that you can save time looking for plugins always.

The first step in doing SHORTCODE is to go to the Web Folders and check this path, “/wp-content/themes/yourtheme/” then open the file “functions.php.”
After that, locate the end of the PHP file then think of the tag and function name that you will be using. We can use those things here.
Add these codes in the latter part of your “functions.php” before the end of your PHP file.

After that, use this function name to create a function you want to make. For example, you want to display a bunch of words like this “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae sapien pellentesque habitant morbi tristique senectus. Sed risus ultricies tristique nulla. Mi ipsum faucibus vitae aliquet. Et tortor consequat id porta nibh. Leo integer malesuada nunc vel risus commodo viverra maecenas accumsan. Diam quis enim lobortis scelerisque fermentum dui faucibus in. Non diam phasellus vestibulum lorem. Mauris pellentesque pulvinar pellentesque habitant. Ac tortor dignissim convallis aenean et tortor at risus viverra. Sed velit dignissim sodales ut eu sem integer vitae. Eu augue ut lectus arcu bibendum at varius” in 10 posts and pages, instead of copying and pasting it on the pages or posts one by one, let’s make a SHORTCODE for it so that in every alteration, all of the posts/pages will be updated.

Then save the functions.php and use the SHORTCODE in your posts.

How about when you want to display all the user display names on the site and put it on a table? You can also create a SHORTCODE that has database involve.

But it is not only for display, but you can also use SHORTCODE in a process like inserting, updating and deleting data in your database. For example, you need to put the information of users like Display Names and Email in the new table created of your new plugin installed. You need to get first the information user then insert it into the table.

Send us your questions on G Suite

6 + 9 =

Related Blog Post

What is Ajax?

What is Ajax?

Ajax and javascript are great for creating dynamic web applications, but before we discuss the AJAX let us first talk about how the browser works. The browser gets information to display a page. How does it work? When a browser request a page from the website the...

Microsoft Azure

Microsoft Azure

Today we are living in the internet era or what commonly known as “Information age.” A lot of technology invented rapidly, like chatbot, web application like Facebook, Twitter, Instagram, and Snapshot, etc., but have you ever think that how did you access these kind...

The Never Endless Bug

The Never Endless Bug

Bug? If you are an ordinary person the one inlet in your mind about a bug is like a pesky worm or virus, but no, as a developer in our daily working experience we always encounter different bugs. That was super annoying but we have no choice because debugging is a...