WordPress.org

Ready to get started?Download WordPress

Forums

Syntax error for simple plugin I want to develop (1 post)

  1. krystiank
    Member
    Posted 1 year ago #

    Hi All,

    I am totally new to Plugin development.

    What I basically did is I copied a snippet of code I want to reuse as a plugin and call it via a function.

    I am not sure what ls wrong here but basically it does not work.

    Can you please review and point me to the line I need to correct.

    <?php
    /*
    Plugin Name: Children Menu
    Plugin URI: http://www.bolderimage.com
    Description: This is a really simple script to display children only link navigation for secondary pages
    Version: 1.0
    Author: Bolderimage.com
    Author URI: http://www.www.bolderimage.com
    Update Server:
    Min WP Version: 3.2.1
    Max WP Version:
    */
    
    function children_menu() {
    	global $post;
    	if(!$post->post_parent){
    	// will display the subpages of this top level page
    		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    		$titlenamer = get_the_title($post->ID);
    	}else{
    	// diplays only the subpages of parent level
    	//$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    
    	if($post->ancestors)
    	{
    		// now you can get the the top ID of this page
    		// wp is putting the ids DESC, thats why the top level ID is the last one
    		$ancestors = end($post->ancestors);
    		$children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0");
    		$titlenamer = get_the_title($post->post_parent);
    		// you will always get the whole subpages list
    	}
    }
    
    if ($children) {
    echo '<div id="left-nav">';
    echo '	<ul> ';
    		$children;
    echo '</ul>';
    }
    echo '</div>';
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.