Support » Themes and Templates » Object unavailable inside content.php

  • Resolved JonathanMH


    I have a class in my themes function.php. Calling methods of the created object works fine in index.php, but not in content.php.

    The error I get:
    Fatal error: Call to a member function post_thumbnail() on a non-object in [path of file]

    var_dump for my object in index.php:
    object(Ancestor)#168 (0) { }

    var_dump for my object in content.php:

    My thought is, that is has something to do with

    How can I work around this?

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


    Just tested, using:
    require_once( 'content.php' . get_post_format() );
    works and makes the object available. Now I just need to build a fallback, if a file isn’t there.

    Kind of weird, that it works this way and not the other though.



    Aha! <?php global $object_name; ?> in the top of every file works!


    applying oop to wordpress themes

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Object unavailable inside content.php’ is closed to new replies.