How do I use a shortcode in WordPress?

Shortcode is very useful in wordpress site. You can create little micros code. Shortcode can html and other code is inserted dynamically directly into the post or website where the user needs them to appear.

You Can Change meany thing in your website useniing Shortcode. I give you some list in below

  • You can add your meta tag without using any plugin
  • You can add or change text or html tag in your post

Example

1:- Create shortcode function in your funcaton.php page.

function wp_shortcode() {

// Things that you want to do.
$message = 'welcome to w3-html.com!';
return $message;
}

// register shortcode

add_shortcode('w3Shortcode', 'wp_shortcode');

2. Upside code to shortcode development. Shortcode name is now used in shortcode in your wordpress to “w3Shortcode” 2 way.

A. You can now use the following code to add the shortcode to your posts, websites, and widgets:


[w3Shortcode]
 

B. If you use php-code shortcode.


<?
echo do_shortcode( '[w3Shortcode]' )>
?>
 
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments