WordPress.org

Ready to get started?Download WordPress

Forums

Call to a member function main() on a non-object (3 posts)

  1. Webnet
    Member
    Posted 5 years ago #

    I'm trying to use wordpress for my site, however I just want to use the back end for users to edit my content and completely customize the front end. Rather than editing templates, I want to include wordpress in one of my classes and basically remove the wordpress header/footer.

    I'm new to wordpress, so anyone else's experience or feedback on how I'm doing this would be greatly appreciated.

    <?php
    class GamerSourceApplicationSiteArticleView extends GamerSourceApplicationSitePage {
    	/*===========================================*/
    	/* Public Functions
    	/*===========================================*/
    	function authenticate () {
    		return true;
    	}
    	function show () {
    		/**
    		 * Front to the WordPress application. This file doesn't do anything, but loads
    		 * wp-blog-header.php which does and tells WordPress to load the theme.
    		 *
    		 * @package WordPress
    		 */
    
    		/**
    		 * Tells WordPress to load the WordPress theme and output it.
    		 *
    		 * @var bool
    		 */
    		define('WP_USE_THEMES', true);
    
    		/** Loads the WordPress Environment and Template */
    		require($this->tru->config->get("root.path")."/author/wp-blog-header.php");
    		// end word press
    
    	}
    //..... class continues, but this is the only function that "shows" content

    Through doing that, I originally had an error with set_prefix because $wpdb was not global. So I changed my wp-settings.php to global it and it works. However I"m now receiving the following error:

    Fatal error: Call to a member function main() on a non-object in C:\wamp\www\gamer-source\author\wp-includes\functions.php on line 1111

    Line 1111 is `function wp( $query_vars = '' ) {
    global $wp, $wp_query, $wp_the_query;
    $wp->main( $query_vars ); //line 1111

    if( !isset($wp_the_query) )
    $wp_the_query = $wp_query;
    }`

    Any thoughts?

  2. Webnet
    Member
    Posted 5 years ago #

    I've worked with this again and still can't get it to work.

  3. xmanoux
    Member
    Posted 5 years ago #

    You need to do the require outside any classes or functions.
    I don't have a better solution. But it works.

Topic Closed

This topic has been closed to new replies.

About this Topic