0

I'm trying to create visual composer extension that displays all the child pages.

Somehow it only displays "Array".

Any ideas?

function childpages_func( $childpages = '' ){
      $childpages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID);
        foreach($childpages as $child){
            "<div>
                <a href='.get_page_link($child->ID).' title='.$child->post_title.'>
                    <img src='.wp_get_attachment_url(get_post_thumbnail_id($child->ID)).' title='.$child->post_title.'>
                </a>
            </div>";
        }
        return $childpages;
    }

    /* Display Child Pages */
    function vc_doo_clip_child_pages_func( $atts ) {
     extract( shortcode_atts( array(
            'cp_header' => 'cp_header'
        ), $atts ) );
         $end_content = '<h2>'.$cp_header.'</h2>'.childpages_func().'';

            return $end_content;
    }

Any help will be greatly appreciated ;) Thanks!

| improve this question | | | | |
0

You shouldn't return childpages, you should add variable $ret=""; and in each cycle append

foreach(...){
   $ret.="<div...";
}

and return it

In general you should always return a string(or number) in such functions

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.