Contentful logo

Contentful Community

Getting the "Content Type ID"

Hello, I am trying to get the Content Type ID of a linked entry. I am using PHP SDK, but am having trouble aquiring it. Below is snippet of what I have and what I am trying to do.

$query = new Contentful\Delivery\Query();
$query->setContentType(‘featuredContent’)->where(‘fields.titleSlug’, ‘all-users’)->setInclude(2);
$entry = $client->getEntries($query);

For the “all-users” entry, I have a linked field (“homePageFeatured") that references other entries. For each of those entries, I need the "content type ID”.

If I use “$entry[0]->homePageFeatured[0]->title”, I indeed get the entry title which is great, however when I do “$entry[0]->homePageFeatured[0]->contentTypeId ”, I am expecting to get back “article” which is the content type of the referenced entry.

Can you be more specific on the syntax to use? Again, I am using PHP.

Hi @danny
Could you confirm what version of the PHP SDK you’re using?