Skip to content

Instantly share code, notes, and snippets.

@hanamizuki
Last active December 9, 2015 21:08
Show Gist options
  • Save hanamizuki/4328276 to your computer and use it in GitHub Desktop.
Save hanamizuki/4328276 to your computer and use it in GitHub Desktop.
In a view
<?php print count(views_get_current_view()->result); ?>
Not in a view
<?php
$view = views_get_view('MY_VIEW_NAME');
$view->set_display('MY_DISPLAY'); // like 'block_1'
$view->render();
print sizeof($view->result);
?>
Or
$view = views_get_view_result('MY_VIEW_NAME', 'DISPLAY_ID(OPTIONAL)');
$view_count = count($view);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment