kalponikoronno

one page theme shortcode

Feb 18th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. function pagecontent_shortcode($atts, $content = null) {
  2.         extract(shortcode_atts(array(
  3.             'pslug' => '',
  4.         ), $atts));
  5.             $q = new WP_Query(
  6.                 'pagename='.$pslug.''
  7.             );
  8.                 $list .= '
  9.    <section id="'.$pslug.'">
  10.        <div class="container">
  11.                 ';
  12.                     while($q->have_posts()) : $q->the_post();
  13.                         $idd = get_the_ID();
  14.                         $pagesubtitle = get_post_meta($idd, 'pagesubtitle', true);
  15.                        
  16.                         $list .= '
  17.                      <div class="row">
  18.                            <div class="col-lg-12 text-center">
  19.                               <h2 class="section-heading">'.get_the_title().'</h2>
  20.                                  <h3 class="section-subheading text-muted">'.$pagesubtitle.'</h3>
  21.                        
  22.                             </div>
  23.                     </div>
  24.                    
  25.                         <p>'.get_the_content().'</p>
  26.                         ';     
  27.                        
  28.                     endwhile;
  29.                 $list .= '
  30.        </div>
  31.    </section>
  32.                 '; 
  33.             wp_reset_query();                  
  34.         return $list;
  35. }
  36. add_shortcode('pagepost', 'pagecontent_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment