How to make shortcode in wordpress

How to make shortcode in wordpress

February 17, 2012

Shortcode is a set of function to use in your post/page content. For instance, we use contact form 7 or any gallery plugin, we use a simple code to put in our post/page content:

[contactform]

Its really easy to built. Shortcode is define in your theme file function.php. Below is a simple example to built the shortcode.

function my_short_code( $atts ){
$code = “Shortcode is really easy.”;
return $code ;
}
add_shortcode( ‘my_code’, ‘get_zipcode’ );

Now we can use [my_code] as short code in our post/page content. It will generate “Shortcode is really easy” as output.

Related Posts

from my blog


How To Get Hired as a Remote WordPress Developer in 2025

February 14, 2025

In 2025, with the growing demand for remote development and the constantly evolving web landscape, there are many exciting possibilities to become a remote WordPress developer. You can achieve success...

Hire WordPress Experts: Building Your Online Presence with Confidence

April 10, 2024

WordPress can help you create an online presence that is effective for your company. WordPress is a top-rated content management system. To harness its power, you need WordPress specialists. What...

Why Should Your Hire Freelance Web Developer: The Top Benefits

May 17, 2022

When developing a website or an app, there are two major ways to do it - outsource the job to a web development company or hire a freelancer to get...