top of page

Creating a shortcode in Wordpress

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Aug 28, 2020
  • 1 min read

Creating a short code in word press can be handy at times


Assume following code from functions.php


function add_content_buttons($atts){

	$atts = shortcode_atts(
        array(
            'text' => '',
            'url'  => '',
            'color'=> '#000'
        ), $atts, 'bartag' );

    return '<a style="color:'.$atts['color'].'" class="postcardstarthere btn build-list" href="'.$atts['url'].'">'.$atts['text'].'</a>';
}

add_shortcode('content_buttons','add_content_buttons' );

The short code in back end look like


The Display in front end Looks Like



The code in active theme's functions.php looks like





 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page