How to create a custom short code for getting data from database table in wordpress?
// 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');
POST COMMENTS