wordpress - Getting post ID within shortcode on page template -
i using plugin called: inpost gallery. have added shortcode page template can show gallery on each page. shortcode has post_id="10" need post id change each page show images below each page, , therefore use code such get_post_id() i'm unable work..
here relevant shortcode-
<?php echo do_shortcode('[inpost_gallery thumb_width="100" thumb_height="100" post_id="10" thumb_margin_left="0" thumb_margin_bottom="0" thumb_border_radius="2" thumb_shadow="0 1px 4px rgba(0, 0, 0, 0.2)" js_play_delay="3000" id="" random="0" group="0" border="" type="yoxview" show_in_popup="0" album_cover="" album_cover_width="200" album_cover_height="200" popup_width="800" popup_max_height="600" popup_title="gallery"][/inpost_gallery]'); ?>
here template php incorporates shortcode-
<?php // album download start // if ( isset($_get['download']) ) { // header('content-type: application/mp3'); // header('content-disposition: attachment; filename='.basename($_get['download'])); // readfile( $_get['download'] ); // } // album download end get_header(); global $cs_transwitch,$prettyphoto_flag; $prettyphoto_flag = "true"; $cs_album = get_post_meta($post->id, "cs_album", true); if ( $cs_album <> "" ) { $xmlobject = new simplexmlelement($cs_album); $cs_layout = $xmlobject->cs_layout; $cs_sidebar_left = $xmlobject->cs_sidebar_left; $cs_sidebar_right = $xmlobject->cs_sidebar_right; } if ( $cs_layout == "left" ) { $cs_layout = "two-thirds column right"; $show_sidebar = $cs_sidebar_left; } else if ( $cs_layout == "right" ) { $cs_layout = "two-thirds column left"; $show_sidebar = $cs_sidebar_right; } else $cs_layout = "sixteen columns left"; ?> <div id="container" class="container row"> <div role="main" class="<?php echo $cs_layout;?>" > <?php /* run loop output post. * if want overload in child theme include file * called loop-single.php , used instead. */ //get_template_part( 'loop', 'single_cs_album' ); ?> <?php if ( have_posts() ): while ( have_posts() ) : the_post(); ?> <?php //showing meta start $cs_album = get_post_meta($post->id, "cs_album", true); if ( $cs_album <> "" ) { $xmlobject = new simplexmlelement($cs_album); $cs_layout = $xmlobject->cs_layout; $cs_sidebar_left = $xmlobject->cs_sidebar_left; $cs_sidebar_right = $xmlobject->cs_sidebar_right; $album_release_date = $xmlobject->album_release_date; $album_social_share = $xmlobject->album_social_share; $album_buy_amazon = $xmlobject->album_buy_amazon; $album_buy_apple = $xmlobject->album_buy_apple; $album_buy_groov = $xmlobject->album_buy_groov; $album_buy_cloud = $xmlobject->album_buy_cloud; } //showing meta end ?> <div id="post-<?php the_id(); ?>" <?php post_class(); ?>> <h1 class="heading"><?php the_title(); ?></h1> <div class="in-sec"> <?php // getting featured image start $image_id = get_post_thumbnail_id ( $post->id ); if ( $image_id <> "" ) { //$image_url = wp_get_attachment_image_src($image_id, array(208,208),true); $image_url = cs_attachment_image_src($image_id, 208, 208); $image_url = $image_url; //$image_url_full = wp_get_attachment_image_src($image_id, 'full',true); $image_url_full = cs_attachment_image_src($image_id, 0, 0); $image_url_full = $image_url_full; } else { $image_url = get_template_directory_uri()."/images/admin/no_image.jpg"; $image_url_full = get_template_directory_uri()."/images/admin/no_image.jpg"; } //$image_id = get_post_thumbnail_id ( $post->id ); //$image_url = wp_get_attachment_image_src($image_id, array(208,198),true); //$image_url_full = wp_get_attachment_image_src($image_id, 'full',true); // getting featured image end ?> <div class="light-box album-tracks album-detail <?php if($image_id == "") echo "no-img-found";?> "> <div id="main-container"> <div id="leftcolumn"> <a rel="prettyphoto" name="<?php the_title(); ?>" href="<?php echo $image_url_full?>" class="thumb" > <?php echo "<img src='".$image_url."' />";?> </a> <br> <br> <div id="inpostgallery"><?php echo do_shortcode('[inpost_gallery thumb_width="104" thumb_height="104" post_id="10" thumb_margin_left="0" thumb_margin_bottom="0" thumb_border_radius="2" thumb_shadow="0 1px 4px rgba(0, 0, 0, 0.2)" js_play_delay="3000" id="" random="0" group="0" border="" type="yoxview" show_in_popup="0" album_cover="" album_cover_width="200" album_cover_height="200" popup_width="800" popup_max_height="600" popup_title="gallery"][/inpost_gallery]'); ?></div> </div> <div id="rightcolumn"> <div class="desc"> <p style="font-size:12px;"><span class="bold" style="text-transform:uppercase; color:#262626;"><?php _e('categories', csdomain); ?> :</span> <?php /* translators: used between list items, there space after comma */ $before_cat = " ".__( '',csdomain ); $categories_list = get_the_term_list ( get_the_id(), 'album-category', $before_cat, ', ', '' ); if ( $categories_list ): printf( __( '%1$s', csdomain ),$categories_list ); endif; '</p>'; ?> </p> <br> <h4><?php _e('description', csdomain); ?></h4> <div class='txt rich_editor_text'> <?php the_content(); ?> </div> <div class="clear"></div> <?php edit_post_link( __( 'edit', csdomain ), '<span class="edit-link">', '</span>' ); ?> </div></div> </div> <div class="clear"></div> </div> </div> <div class="in-sec"> <div class="album-opts"> <div class="share-album"> <?php $cs_social_share = get_option("cs_social_share"); if($cs_social_share != ''){ $xmlobject_album = new simplexmlelement($cs_social_share); if($album_social_share == 'yes'){ social_share(); }?> <?php }?> </div> <?php if($album_buy_amazon != '' or $album_buy_apple != '' or $album_buy_groov != '' or $album_buy_cloud != ''){?> <div class="availble"> <h4><?php if($cs_transwitch =='on'){ _e('buy this',csdomain); }else{ echo __cs('buy_now', 'buy this'); }?></h4> <?php if ( $album_buy_amazon <> "" ) echo ' <a target="_blank" href="'.$album_buy_amazon.'" class="amazon-ind"> <span>';if($cs_transwitch =='on'){ _e('amazon',csdomain); }else{ echo __cs('amazon', 'amazon'); } echo '</span></a> '; if ( $album_buy_apple <> "") echo ' <a target="_blank" href="'.$album_buy_apple.'" class="apple-ind"> <span>'; if($cs_transwitch =='on'){ _e('apple',csdomain); }else{ echo __cs('itunes', 'itunes'); } echo '</span></a> '; if ( $album_buy_groov <> "") echo ' <a target="_blank" href="'.$album_buy_groov.'" class="grooveshark-ind"> <span>'; if($cs_transwitch =='on'){ _e('grooveshark',csdomain); }else{ echo __cs('grooveshark', 'grooveshark'); } echo '</span></a> '; if ( $album_buy_cloud <> "") echo ' <a target="_blank" href="'.$album_buy_cloud.'" class="soundcloud-ind"> <span>'; if($cs_transwitch =='on'){ _e('soundcloud',csdomain); }else{ echo __cs('soundcloud', 'soundcloud '); } echo '</span></a> '; ?> </div> <?php }?> <div class="clear"></div> </div> </div> <?php foreach ( $xmlobject $track ){ if ( $track->getname() == "track" ) { ?> <div class="in-sec"> <?php enqueue_alubmtrack_format_resources(); ?> <div class="album-tracks light-box"> <?php $counter = 0; foreach ( $xmlobject $track ){ $counter++; if ( $track->getname() == "track" ) { echo "<div class='track'>"; echo "<h5>"; echo $album_track_title = $track->album_track_title; echo "</h5>"; echo "<ul>"; if ($track->album_track_playable == "yes") { echo ' <li> <div class="cp-container cp_container_'.$counter.'"> <ul class="cp-controls"> <li><a style="display: block;" href="#" class="cp-play" tabindex="1"> <span>'; if($cs_transwitch =='on'){ _e('play',csdomain); }else{ echo __cs('play', 'play'); } echo '</span></a></li> <li><a href="#" class="cp-pause" style="display: none;" tabindex="1"> <span>'; if($cs_transwitch =='on'){ _e('pause',csdomain); }else{ echo __cs('pause', 'pause'); } echo '</span></a></li> </ul> </div> <div style="width: 0px; height: 0px;" class="cp-jplayer jquery_jplayer_'.$counter.'"> <img style="width: 0px; height: 0px; display: none;" id="jp_poster_0"> <audio src="'.$track->album_track_mp3_url.'" preload="metadata" ></audio> </div> <script> jquery(document).ready(function($){ var mycircleplayer = new circleplayer(".jquery_jplayer_'.$counter.'", { mp3: "'.$track->album_track_mp3_url.'" }, { cssselectorancestor: ".cp_container_'.$counter.'", swfpath: "'.get_template_directory_uri().'/scripts/frontend/jplayer.swf", wmode: "window", supplied: "mp3" }); }); </script> </li> '; } if ($track->album_track_downloadable == "yes"){ echo '<li><a href="'.$track->album_track_mp3_url.'" class="download"> <span>'; if($cs_transwitch =='on'){ _e('download',csdomain); }else{ echo __cs('download', 'download'); } echo '</span></a></li>'; } if ($track->album_track_lyrics <> "") { echo '<li><a href="#lyrics'.$counter.'" rel="prettyphoto[inline]" title="'.$album_track_title.'" class="lyrics"> <span>'; if($cs_transwitch =='on'){ _e('lyrics',csdomain); }else{ echo __cs('lyrics', 'lyrics'); } echo '</span></a></li>';} if ($track->album_track_buy_mp3 <> ""){ echo '<li><a href="'.$track->album_track_buy_mp3.'" class="buysong"> <span>'; if($cs_transwitch =='on'){ _e('buy song',csdomain); }else{ echo __cs('buy_now', 'buy song'); } echo '</span></a></li>';} echo "</ul>"; echo ' <div id="lyrics'.$counter.'" style="display:none;"> '.str_replace("\n","</br>",$track->album_track_lyrics).' </div> '; echo "</div>"; } } ?> <div class="clear"></div> </div> </div> <?php } } ?> <div class="clear"></div> <?php if ( get_the_author_meta( 'description' ) ) :?> <div class="in-sec" style="margin-top:20px;"> <div class="about-author"> <div class="avatars"> <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'pixfill_author_bio_avatar_size', 53 ) ); ?> </div> <div class="desc"> <h5><a href="<?php echo get_author_posts_url( get_the_author_meta( 'id' ) ); ?>"><?php _e('about', csdomain); ?> <?php echo get_the_author(); ?></a></h5> <p class="txt"> <?php the_author_meta( 'description' ); ?> </p> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <?php endif; ?> </div> <?php endwhile; endif; // end of loop. ?> <?php comments_template( '', true ); ?> </div> <?php if( $cs_layout != "sixteen columns left" , isset($show_sidebar) ) { ?> <!--sidebar start--> <div class="one-third column left"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($show_sidebar) ) : ?> <?php endif; ?> </div> <!--sidebar ends--> <?php }?> <div class="clear"></div><!-- #content --> </div><!-- #container --> <div class="clear"></div> <?php get_footer(); ?>
you can concatenate id string returned value get_the_id()
:
<?php echo do_shortcode("[inpost_nivo slide_width='600px' slide_height='auto' thumb_width='75' thumb_height='75' post_id='" . get_the_id() . "' skin='light' transition_effect='random' transition_speed='600' autoslide='5000' control_nav='1' control_nav_thumbs='1' direction_nav='1' direction_nav_hide='0' controlnavthumbs='0' random_start='0' pause_on_hover='1' show_description='1' box_rows='4' box_cols='8' slices='15' start_slide='0' id='' random='0' group='0' show_in_popup='0' album_cover='' album_cover_width='200' album_cover_height='200' popup_width='800' popup_max_height='600' popup_title='gallery' type='nivo'][/inpost_nivo]"); ?>
Comments
Post a Comment