Forums

[resolved] Template Tutorial - Error (4 posts)

  1. Tsalagi
    Member
    Posted 2 years ago #

    I'm currently leearning to create templates in WordPress. I've downloaded a tutorial from Nettuts.com. I'm creating the functions.php file and I am getting an error.

    I've commented out the code in blocks and found the block I think is causing php to complain. Here is the block of code from the `functions.php file.
    //get pages into a drop-down list
    $pages_list = get_pages();
    $getpag = array();
    foreach($pages_list as $page) {
    $getpag[$apage->ID] = $apage->post_title;
    }
    $page_dropdown = array_unshift($getpag, "Select a page:");`
    Here is the error:
    Catchable fatal error: Object of class stdClass could not be converted to string in C:\wamp\www\wordpress\wp-includes\classes.php on line 273
    Here is the area of the classes.php file targeted in the error.

    for ($i=0; $i<count($this->public_query_vars); $i += 1) {
    			$wpvar = $this->public_query_vars[$i];
    			if (isset($this->extra_query_vars[$wpvar]))
    				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
    			elseif (isset($GLOBALS[$wpvar]))
    				$this->query_vars[$wpvar] = $GLOBALS[$wpvar];
    			elseif (!empty($_POST[$wpvar]))
    				$this->query_vars[$wpvar] = $_POST[$wpvar];
    			elseif (!empty($_GET[$wpvar]))
    				$this->query_vars[$wpvar] = $_GET[$wpvar];
    			elseif (!empty($perma_query_vars[$wpvar]))
    				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
    
    			if ( !empty( $this->query_vars[$wpvar] ) ) {
    				$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
    				if ( in_array( $wpvar, $taxonomy_query_vars ) ) {
    					$this->query_vars['taxonomy'] = $taxonomy_query_vars[$wpvar];
    					$this->query_vars['term'] = $this->query_vars[$wpvar];
    				}
    			}
    		}

    The code specified in line 273 is
    $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
    This may be directly related to PHP or maybe a bug in the new WordPress release. Any thoughts would be appreciated.

  2. Tsalagi
    Member
    Posted 2 years ago #

    I've resolved this issue by finding an error in my own code. "apage" duh

  3. termserv
    Member
    Posted 2 years ago #

    What did you do to fix it?

  4. termserv
    Member
    Posted 2 years ago #

    Never mind. Found my problem: You cant use $page or $post as variable, as they are used for holding the pages and posts as objects.

Topic Closed

This topic has been closed to new replies.

About this Topic