Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Stephen O'Connor
Stephen O'Connor
22,291 Points

Where to learn more about PHP Basics, and how to apply that to WordPress.

Hi,

I have a pretty good grasp on WordPress now and I am comfortable setting up a WordPress site with a custom theme, what I am not comfortable with is doing specific things in WordPress, like listing child pages for example - this is only an example, I see many more things in the functions.php file or in templates that I do not really understand.

The code below would list child pages but I don't really understand how the code works.

// List child pages
    function wpb_list_child_pages() { 

        global $post; 
        if ( is_page() && $post->post_parent )
            $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
        else
            $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
        if ( $childpages ) {
            $string = '<ul>' . $childpages . '</ul>';
        }
        return $string;
    }
        add_shortcode('wpb_childpages', 'wpb_list_child_pages');

Is there something I should be learning to do with PHP to understand this better or is this WordPress related? I know I need to have an understanding of PHP to get WordPress but I am not sure where to go to learn more about it all .... or if that is what I should even be doing.

Can anyone offer me some advise?

Thanks.

1 Answer

I think if you generally understand code, for Wordpress you don't need PHP but rather need to dig deeper into WORD PRESS for example in that code you posted I would look at the wp_list_pages() function to see how it works since that code is using it to get the child pages..