Create Shortcode in PHP WORDPRESS

add_shortcode( ‘FEATUREDPOST’, ‘visitor_check_shortcode’ );
function visitor_check_shortcode($atts) {
echo ‘<h3 class=”widget-title”>Premium Biz</h3><div class=”featured-classified-ads”><ul>’;
$cartlimit = get_option(‘my-setting1’);
$limit = $cartlimit . “00”;
$sql = mysql_query(“select * from bbs_awpcp_ads where ad_item_price > ‘$limit’ and disabled = ‘0’ order by ad_id DESC LIMIT 8”);
while($ad = mysql_fetch_array($sql)){
$id = $ad[‘ad_id’];
$ss = mysql_query(“select * from bbs_awpcp_adphotos where ad_id = $id”);
$ks = mysql_fetch_array($ss);
$featuredimage = $ks[‘image_name’];
$src = ‘http://businessforbuysale.com/wp-content/uploads/awpcp/&#8217;.$featuredimage;
$noimg = “no_image.jpg”;
if (@getimagesize($src)) {
$featuredimage = $featuredimage;
}
else
{
$featuredimage = $noimg;
}
echo ‘<a href=”http://businessforbuysale.com/business/show-listing/&#8217;. $ad[‘ad_id’] .’/’. $ad[‘ad_title’].'”><li><img src=”http://businessforbuysale.com/wp-content/uploads/awpcp/&#8217; . $featuredimage .'” /><br /><p>’;
echo custom_echo($ad[‘ad_title’]);
echo “</p></li></a>”;
}
echo “</ul></div>”;

}

SHORTCODE : [FEATUREDPOST] to use

2 thoughts on “Create Shortcode in PHP WORDPRESS

Leave a comment