Use this simple snippet to embed a view in code and only display it if the view has at least one result (prevent rendering empty views markup):
$view = views_get_view('your_view_name');
$view->set_display('your_view_display');
// Only display the view if it has results and the user has access.
if ($view->access('your_view_display')) {
// Example argument
$view->args = array($node->nid);
$view->pre_execute();
$view->execute();
if (!empty($view->result)) {
print $view->get_title() . $view->preview();
}
}
?>