Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function displayChildPage($atts){
- extract(shortcode_atts(array(
- 'parent' => '',
- 'icon' => false,
- 'exclude' => ''
- ), $atts));
- wp_reset_postdata();
- global $post;
- if (empty($parent))
- $parent = $post->ID;
- $output = "";
- $args = array(
- 'orderby' => 'menu_order',
- 'order' => 'ASC',
- 'post_parent__in' => explode( ",", $parent),
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'numberposts' => 24,
- 'post__not_in' => explode(",",$exclude)
- );
- $query = new WP_Query( $args );
- if ( $query->have_posts() ) :
- $i = 0;
- while ( $query->have_posts() ) {
- $query->the_post();
- if($i % 4 == 0) {
- if($i > 0) {
- $output .= '</div>';
- }
- $output .= '<div class="row no-margin gutters split-extra-small">';
- }
- $output .= '<article id="post-' . get_the_ID() . '" class="' . implode(' ', get_post_class('column-6 grid match glow text-center', get_the_ID())) . '">';
- $thumb_id = get_post_thumbnail_id();
- $thumb_url = wp_get_attachment_image_src($thumb_id,'medium', true);
- if ($thumb_id) {
- $output .= '<a href="' . get_permalink() . '"><img src="'. $thumb_url[0] . '" alt="' . get_the_title(get_the_ID()) . '" /></a>';
- } else {
- $output .= '<a href="' . get_permalink() . '"><span class="fa-stack fa-3x"><i class="fa fa-circle fa-stack-2x"></i><i class="icon icon-' . $post->post_name . ' fa-stack-1x"></i></span></a>';
- }
- $output .= '<h3 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title(get_the_ID()) . '</a></h3>';
- $output .= '</article><!-- #post-## -->';
- $i++;
- }
- $output .= '</div>';
- $output .= '<!-- subPage -->';
- endif;
- //
- wp_reset_postdata();
- return $output;
- }
- add_shortcode('childPage', 'displayChildPage');
Advertisement
Add Comment
Please, Sign In to add comment