WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Plugin Views (includes and ob_start) (1 post)

  1. matthewordie
    Member
    Posted 2 years ago #

    I'm creating my first plugin and I'd like to setup some simple view templates for my front end.

    Currently I'm trying something like:

    $title = 'Title';

    // Start a buffer
    ob_start();
    // Include your template
    include('template.php');

    // Get the buffer into a variable
    $return = ob_get_contents();

    // End the buffer
    ob_end_clean();

    This gets the template just fine, but my $title variable does not carry over into the include like usual. This code works fine outside of the constructs of WP. Any idea what might be causing it?

Topic Closed

This topic has been closed to new replies.

About this Topic