I need to get the parent entry_id while I'm inside a relationship. This is what I have - doctors_locations is my relationship field name:

    {doctors_locations:locations_city} {!-- outputs related city --}
    {doctors_locations:parents}{entry_id}{/doctors_locations:parents} {!-- I need the entry_id of the parent in this relationship --}

I've tried different iterations of this to no avail. Everything I've tried seems to cause a memory error -- assuming endless loop?

Is it possible to get the parent entry_id while inside of the relationship loop? I've managed to accomplish the same thing using Playa, but I needed to switch the doctors_locations field type to a Relationship field.

I'm using EE 2.10.1.

UPDATE: Based on the info here: https://ellislab.com/expressionengine/user-guide/add-ons/channel/relationships.html#accessing-parents I should be able to accomplish this. So I updated my code like this (tried it with just the title):

    {doctors_locations:parents field="doctors_locations"}

I get the following error:

Fatal Error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 1 bytes) in ../system/codeigniter/system/database/drivers/mysql/mysql_result.php

1 Answer 1


You're entering an infinite recursive loop with your code there, hence the memory exhaustion. All you need to do is this:

    Location Title: {doctors_locations:title}
    Location Entry ID: {doctors_locations:entry_id}
    Doctor Title: {title}
    Doctor Entry ID: {entry_id}

You would only further use {doctors_locations:parents} if you wanted to fetch parents from a different channel/field than the parent channel you're already in via channel:entries.

  • I appreciate your prompt answer! I figured this out about 15 mins after I posted the original question. It was a "duh" moment! Commented Jun 11, 2015 at 21:57

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.