markirby / Chester-WordPress-MVC-Theme-Framework

A lightweight wordpress MVC theming framework for people who want to build their own custom themes with an MVC approach
http://markirby.github.com/Chester-WordPress-MVC-Theme-Framework/
40 stars 16 forks source link

capturing wordpress output #4

Open digitalmoran opened 10 years ago

digitalmoran commented 10 years ago

Thanks for providing this example framework. In the documentation examples, you express that you want to return wp_head() and other WP functions as string values. You can accomplish this with output buffering like so:

 /**
  * Fetches Wordpress Menu markup for specified theme location
  * @var string $theme_location
  * @return string
  */
  public function getMenuContent($theme_location) {
      ob_start();
      wp_nav_menu( array( 'theme_location' => $theme_location ) );
      $menu = ob_get_clean();
      return $menu;
  }
markirby commented 10 years ago

Thanks! That looks like an ideal solution. I will update this in the next version.