• abcape11

    (@abcape11)


    I was trying to add this code to my functions.php file in my theme…

    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 = ‘

      ‘ . $childpages . ‘

    ‘;
    }
    return $string;
    }
    add_shortcode(‘wpb_childpages’, ‘wpb_list_child_pages’);

    and got this error.

    Parse error: syntax error, unexpected T_LNUMBER in /home/content/24/5971324/html/wp-content/themes/twentyfourteen/functions.php on line 504

    I am now locked out of the front and backend of wordpress. Please help. SOS!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter abcape11

    (@abcape11)

    There’s a few brackets missing in the code you posted above. Try this:

    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 = '' . $childpages . '';
    		}
    		return $string;
    	}
    }
    
    add_shortcode('wpb_childpages', 'wpb_list_child_pages');

    Untested code, not sure what you’re trying to do with it, but if the syntax/structure is wrong then it will block everything else.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Parse error: syntax error, unexpected T_LNUMBER in…’ is closed to new replies.