Get page content shortcode

function sgspcontent($atts) {

$sgsppostid = intval($atts[postid]);
$output = '';

query_posts("p=$sgsppostid");
if (have_posts()) : while (have_posts()) : the_post();
$output .= get_the_content($post->ID);
endwhile; else:
// failed, output nothing

endif;
wp_reset_query();

return $output;

}
add_shortcode("includepost", "sgspcontent");

Improved Shortcode

<?php

/* ~~~~~~~~~~~~ Test Routine ~~~~~~~~~~~~*/

//Default Style
hgm_map();

//Array Style
$test_args = array('width' => 500, 'height' => 300);
hgm_map($test_args);

//Query String Style
hgm_map('width=200&height=100');

//Shortcode = [hgm_map width="600" height="400"]

/* ~~~~~~~~~~~~ Functions ~~~~~~~~~~~~*/

/* Main Function */
function hgm_map($args,$shortcode = false){
if($shortcode) ob_start(); //Halt output if shortcode

//Apply defauilts to argumentns and extract
$defaults = array(
'width' => '600',
'height' => '400'
);
$final_args = wp_parse_args($args,$defaults);
extract($final_args,EXTR_SKIP);
?>

<p>Width Value = <?php echo $width ?></p>
<p>Height Value = <?php echo $height ?></p>

<?php
if($shortcode){
$main_function_output = ob_get_contents();
ob_end_clean();
return $main_function_output;
}
}

/* Shortcode - [hgm_map width="600" height="400"] */
function hgm_shortcode($args){ return hgm_map($args,true); }
add_shortcode('hgm_map','hgm_shortcode');

?>

Dynamic text with shortcode

<?php

//Text Shortcode
/** Print Text **/
function wco_print_text($shortcode = false,$term = '',$poss = false){
if($shortcode) ob_start();
if($poss) $extra_text = '&#8217;s'; //Possessive ('s)
$option = get_blog_option(1,'wco_text_' . $term); //Use get_option() for non-multisite
if($option) echo $option . $extra_text;
else echo '**' . strtoupper($term) . $extra_text;
if($shortcode){
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
/** Shortcode Print Text [wco_text term="location" poss="1"] **/
function wco_shortcode_print_text($atts){
extract(shortcode_atts(array('term' => '','poss' => false),$atts));
return wco_print_text(true,$term,$poss);
}
add_shortcode('wco_text','wco_shortcode_print_text');

?>

Function as Shortcode

/*
Function as Shortcode Technique

Run functions in "Shortcode Mode" - If functions used for shortcode are output to the browser they will display above whatever content you place in your pages or posts. Not good. This method eliminates the need to write "mirrored" funcitons of your main ones just for shortcode.
*/

//Main plugin function
function main_function($shortcode = false){
if($shortcode) ob_start(); //If shortcode halt browser output

$testvar = 'This is an output test on: ' . $_SERVER['HTTP_HOST'];

?>
<div class="test">
<p><?php echo $testvar; ?></p>
</div>
<?php

//If shortcode store output in variable and return
if($shortcode){
$main_function_output = ob_get_contents();
ob_end_clean();
return $main_function_output;
}
}

//Run Shortcode - [my_shortcode]
function run_my_shortcode($atts){
extract(shortcode_atts(array(
'arg1' => 'Not Set',
'arg2' => 'Not Set'
), $atts));

return main_function(true);
}

add_shortcode('my_shortcode','run_my_shortcode');
?>