short code
允许非编程人员直接使用的功能函数,并且可以添加属性等,类似标签( from v2.5 on)
1 <?php 2 /* 3 Plugin Name: Map plugin using shortcode 4 Plugin URI: http://www.falkonproductions.com/shortcodeMaps/ 5 Description: This plugin will get a map of whatever parameter is passed. 6 Author: Drew Falkman 7 Version: 1.0 8 Author URI: http://www.falkonproductions.com/ 9 */ 10 11 function smp_map_it($atts,$content=null) 12 { 13 shortcode_atts( array( 'title' => 'Your Map:', 'address' => ''), $atts); 14 $base_map_url = 'http://maps.google.com/maps/api/staticmap?sensor=false&size=256x256&format=png¢er='; 15 return ' 16 <h2>' . $atts['title'] . '</h2> 17 <img width="256" height="256" 18 src="' . $base_map_url . urlencode($atts['address']) . '" />'; 19 } 20 21 add_shortcode('map-it','smp_map_it');
然后,在post里可以直接使用:
[map-it title="our location" address="los Agel, CA"]
就可以加入google地图
浙公网安备 33010602011771号