Error in displaying shortcode content
-
I am creating a custom plugin for adding news feeds to my website.Using a short code for adding the feeds to a specific page.But the feeds are displaying in all the pages.can someone please help
function Feed_Details(){ global $wpdb; $table_name = $wpdb->prefix."skoop_category"; $category_db = $wpdb->get_results( " SELECT * FROM $table_name WHERE id=1 " ); foreach ( $category_db as $category_db_value ) { $category_name= $category_db_value->category; } $url = site_url(); $service_url = "My API Call"; $url2="&&url="; $result = sprintf("%s%s%s%s",$service_url,$category_name,$url2,$url); echo($result ); $curl = curl_init($result); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $curl_response = curl_exec($curl); if(!$curl_response || strlen(trim($curl_response)) == 0) { ?> <h1> Sorry No Content to Show </h1> <?php }else{ $decoded = json_decode($curl_response,TRUE); $numOfCols = 4; $rowCount = 0; $bootstrapColWidth = 12 / $numOfCols; ?> <div class="row"> <?php if(empty($decoded)){ ?> <div class="no-data" <h4> No Data available in this Category </h4> </div <?php }else{ foreach ($decoded as $key =>$value) { $data=get_data($value); ?> <div class="col-md-<?php echo $bootstrapColWidth; ?>"> <div class="thumbnail"> <img />"> <a>"> <?php echo $data[2]; ?></a> <p><?php echo $data[3]; ?> </p> </div> </div> <?php $rowCount++; if($rowCount % $numOfCols == 0) echo '</div><div class="row">'; } } ?> </div> <?php } } add_shortcode('feed_details', 'Feed_Details'); add_action( 'the_content', 'Feed_Details' ); add_action('admin_menu', 'Skoop'); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Error in displaying shortcode content’ is closed to new replies.