Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created November 6, 2013 14:32
Show Gist options
  • Save gicolek/7336981 to your computer and use it in GitHub Desktop.
Save gicolek/7336981 to your computer and use it in GitHub Desktop.
Get post id from shortcode
<?php
add_shortcode( 'table', 'ssl_table_shortcode' );
/**
* Render ACF table shortcode given several parameters
*/
function ssl_table_shortcode($atts) {
global $post;
// extract the necessary attributes
extract( shortcode_atts( array(
'type' => '1',
), $atts ) );
// get the html for given table type
switch ( $type ) {
case '1':
$out = ssl_tab_one( $post->id );
break;
case '2':
$out = ssl_tab_two( $post->id );
break;
case '3':
$out = ssl_tab_three( $post->id );
break;
}
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment