3229 readersIncludes are a very handy functionnality of the PHP language. Unfortunely, there's no built in solution to include posts in other posts in WordPress. Today's recipe is a shortcode that will allow you to finally do includes. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for
4135 readersI had the occasion yesterday to have a page with a section on it where it would output a very specific set of other pages, which would need to change dynamically. What I could have done is built a special page template for this page, and inside that template run a query_posts() to get these
2823 readersWe covered how to run a shortcode in a widget. But what about inserting a widget with a shortcode? I recently had this situation come up. I had a single page where I just wanted to be able to chuck in a widget without the whole rigmarole of creating a special widgetized area and probably
2916 readersDavid Hollander of SparkWeb Interactive sent us in a little code clip for inserting Google Maps into Posts/Pages by the use of shortcodes. Google actually has copy-and-pastable iframe code already in Google Maps that is really easy to snag, but David was having problems with the Visual text editor screwing up the code when saving
1338 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
4643 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
8681 readers
PHP
function content_countdown($atts, $content = null){
extract(shortcode_atts(array(
'month' => '',
'day' => '',
'year' => ''
), $atts));
$remain = ceil((mktime( 0,0,0,(int)$month,(int)$day,(int)$year) - time())/86400);
if( $remain > 1 ){
6251 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
11335 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
6381 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