![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/imgs/post01.jpg)
How to create a custom short code for getting data from database table in wordpress?
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/imgs/kand5.png)
// wordpress custom shortcode by wpdevkit.in function sdSlidesShortCode($attr){ $array = shortCodeAtts(array( 'id' => '', ), $attr); global $wpdb; $table_name = $wpdb->prefix . ""; $id = $array['id']; $results = $wpdb->get_results("SELECT * FROM $table_name WEHERE ID = '$id'"); foreach($results as $result){ $slidesContent = $result->slidesContent; } $output = $slidesContent; return $output; } add_shortcode('SlideShortCode','sdSlidesShortCode');
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/author.jpg)
POST COMMENTS