Display title of child pages in shortcode

Question

I’m having a hard time figuring out how to display the title of the childpages as the id of a div. Assuming that ‘news’ & ‘othernews’ are siblings of the parent page home (39)

I want something like this:

<div class="wrapper" id="news">
content
</div>
<div class="wrapper" id="othernews">
content
</div>

This is my function for my shortcode:

function content_block( $atts, $content = null ){

extract( shortcode_atts( array(
    'type'          =>      'white'

), $atts));

$childArgs = array(
    'post_type'         =>      'page',
    'parent_page'       =>      39
);

$child = new WP_Query($childArgs);

if ($child->have_posts()) {

    while ($child->have_posts()) {

        $child->the_post();

        if ($type == 'white') {
            $return .= '<div class="col-white">';
                $return .= '<div class="wrap" id="'. get_the_title() .'">';
                    $return .= do_shortcode($content);
                $return .= '</div>';
            $return .= '</div>';

        } else
        if ($type == 'grey') {
            $return .= '<div class="col-grey">';
                $return .= '<div class="wrap" id="'. get_the_title() .'">';
                    $return .= do_shortcode($content);
                $return .= '</div>';
            $return .= '</div>';
        }

        wp_reset_query();
        return $return;
    }
}

}
0
, Jeroen Bellemans 9 years 2014-11-20T08:34:29-05:00 0 Answers 75 views 0

Leave an answer

Browse
Browse