I have content type page with node called blog(page blog) and I want to display all content type blog in it(content of page blog). how can i do this in theme without using block or views.I'm try to do it by using this code:

$build = array();
$query = db_select('node', 'n')->extend('PagerDefault');
$nids = $query
    ->fields('n', array('nid', 'sticky', 'created'))
    ->condition('type', 'blog')
    ->condition('status', 1)
    ->orderBy('sticky', 'DESC')
    ->orderBy('created', 'DESC')

if (!empty($nids)) {
    $nodes = node_load_multiple($nids);
    $build += node_view_multiple($nodes,'full');
    $build['pager'] = array(
        '#theme' => 'pager',
        '#weight' => 5,
else {
    drupal_set_message(t('No blog entries have been created.'));

    print render($build);

and set it in body field for page blog. And when display blog page it's content nothing (or empty page!). I'm test my code and execute it in php code it work and print all blog that I have. Any way to do this in Drupal theme?

1 Answer 1


if I understand correctly you'll need this query:

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'blog')
  ->propertyCondition('status', 1);

$result = $query->execute();

then do you foreach($result);

  • It's same nothing display in page by use your code idea! Thanks
    – BinYarbua
    Mar 19, 2015 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.