3683 readers
You will also notice that some books have multiple ISBN numbers eg: 0578022702, 9780578022703 both should work but grab the first one before the comma. If the book does not have an ISBN number you can get the id from the url.( example screenshot )PHP
add_shortcode('gbooks', 'sc_embed_google_books');
function sc_embed_google_books( $atts ){
extract(shortcode_atts(array(
"id" => '',
"width" => '600',
"height" =>
6181 readers
PHP
function html5_video($atts, $content = null) {
extract(shortcode_atts(array(
"src" => '',
"width" => '',
"height" => ''
), $atts));
return '';
}
add_shortcode('video5', 'html5_video');
SHORTCODE
[video5 src="http://your-site/videos/your-video.mp4" width="720" height="480"]
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it
8419 readersDisplay a snapshot of any website
Want to be able to take a snapshot of any website, and display it on your blog? This cool shortcode allows you to do so. Just paste the following code into your functions.php file:
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" =>
6659 readers
PHP
function wps_screenshot($atts, $content = null) {
extract(shortcode_atts(array(
"screenshot" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://',
"alt" => 'screenshot',
"width" => '400',
"height" => '300'
), $atts));
return $screen = '';
}
add_shortcode("screenshot", "wps_screenshot");
SHORTCODE
[screenshot url="http://wpsnipp.com" alt="wordpress code snippets for your blog" width="200" height="200"]
Visit wpsnipp.com for details on how to setup this
1240 readers
PHP
add_shortcode("my_text", "my_text");
function my_text() {
return 'nested shortcode';
}
function my_link($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
), $atts));
return ''.do_shortcode($content).'';
}
add_shortcode("link", "my_link");
SHORTCODE
[link][my_text][/link]
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it
4505 readersSave time by replacing your most commonly typed words and phrases with WordPress shortcodes. For example, if you are frequently typing your blog’s URL, you could place the following code your theme’s functions.php file: function shortURL() { return 'http://your-site.com/'; } add_shortcode('myurl', 'shortURL'); Now whenever you write a post in “HTML-mode”, you can include your blog’s
3896 readers
PHP
function comments_shortcode($atts) {
extract( shortcode_atts( array(
'id' => ''
), $atts ) );
$num = 0;
$post_id = $id;
$queried_post = get_post($post_id);
$cc = $queried_post->comment_count;
if( $cc == $num || $cc > 1 ) : $cc = $cc.' Comments';
else : $cc = $cc.' Comment';
endif;
$permalink = get_permalink($post_id);
return '' . $cc . '';
}
add_shortcode('comments', 'comments_shortcode');
SHORTCODE
[comments id="23" ]
Visit wpsnipp.com for details on how to setup this
6263 readersRecently, WPRecipes posted an incredibly useful technique that uses a shortcode to add private content to blog posts. This functionality makes it easy to manage leftover data, miscellaneous notes and other communication by keeping everything together with its corresponding post. Consolidating information like this helps to streamline flow and organization into the future.
Combine the power
6994 readers
PHP
add_shortcode( 'youtube', 'my_youtube_shortcode' );
function my_youtube_shortcode( $atts ) {
global $wp_embed;
if ( empty($atts['id']) )
return '';
// Construct the YouTube URL
$url = 'http://www.youtube.com/watch?v=' . $atts['id'];
return $wp_embed->shortcode( $atts, $url );
}
PHP
[youtube id="000000"]
Visit
8716 readers
PHP
function html5_audio($atts, $content = null) {
extract(shortcode_atts(array(
"src" => '',
"autoplay" => '',
"preload"=> 'true',
"loop" => '',
"controls"=> ''
), $atts));
return '';
}
add_shortcode('audio5', 'html5_audio');
SHORTCODE
[audio5 src="http://your-site/videos/your-video.mp4" loop="true" autoplay="autoplay" preload="auto" loop="loop" controls=""]
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it