1

I created a content type. One of the field of the content type is entity term reference. Now I want to fetch the term of the particular content type and load the nodes that contain the term.I used the following code. But does not get the answer. Any error in my concept?

$aupl_node_query = new EntityFieldQuery();
$aupl_referrence = $aupl_node_query
->entityCondition('entity_type',  'taxonomy_term')
->execute();
dpm($aupl_referrence);
$aupl_node = node_load_multiple(array(), $aupl_referrence, true);
1
  • Please accept the answer if you found the answer correct. So, that people can re use that.
    – NTT
    Commented Apr 13, 2016 at 11:12

2 Answers 2

1

You can refer to this article having detailed information about entity queries.

You should use ->entityCondition('entity_type', 'node') rather than using ->entityCondition('entity_type', 'taxonomy_term')

0
0

You need to add condition by taxonomy term ID in your query

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'YOUR_CONTENT_TYPE')
  ->propertyCondition('status', 1)
  ->fieldCondition('YOUR_FIELD_REFERENCE_NAME', 'tid', $YOUR_TAXONOMY_TERM_ID);
$query = $query->execute();

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.