Skip Navigation

[Resolved] meta for post relationships

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use related post metadata in Yoast SEO

Solution: Yoast's support team would be the best resource for information about how to use Yoast. I can provide any information about how posts are related in the database so you can use that information in Yoast.

A child post contains a hidden custom field value that relates it to its parent post. The meta key syntax is as follows:

_wpcf_belongs_parentslug_id

In this example the parent post type slug is parentslug, but yours will be different. If your parent slug is "journal" then the key will be "_wpcf_belongs_journal_id". The meta value is the numeric ID of the parent post, and the post ID is the numeric ID of the child post. So a meta query for "_wpcf_belongs_parentslug_id" where the value = 1234 will find any child posts related to the parent post with ID 1234.

0% of people find this useful.

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by jesseH-3 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#578618

I am trying to: customize the meta (title and description) for my custom post types using Yoast SEO plugin.
I have a custom post type "Article" that is a child of custom post type "Journal"

Link to a page where the issue can be seen: Facebook debugger (hidden link)

I want to see:
For Journal posts: Journal title, (child) article title
For Article posts: Article title, (parent) journal title

Instead, I get:
For Journal posts: Journal title
For Article posts: Article title

I need a way to show parent/child in the post meta. Yoast SEO plugin has a list of variables, but I don't see anything specific to types relationships. Is there a variable I can use?

Or, I wouldn't need a variable if the meta description included text from the body of the single post page, which is outputting (via Views and Layouts) the post title, followed by the parent or child post title, followed by the article content.

#578785

Hi, we're not Yoast SEO experts here, so we're not really qualified to help you use their software. Here's what I can tell you about the relationships between posts and how they're defined by Types. A child post contains a hidden custom field value that relates it to its parent post. The meta key syntax is as follows:

_wpcf_belongs_parentslug_id

In this example the parent post type slug is parentslug, but yours will be different. If your parent slug is "journal" then the key will be "_wpcf_belongs_journal_id". The meta value is the numeric ID of the parent post, and the post ID is the numeric ID of the child post. So a meta query for "_wpcf_belongs_parentslug_id" where the value = 1234 will find any child posts related to the parent post with ID 1234.
As far as using that information in Yoast, I'm afraid I'm not able to offer much help there. If you're able to find out from the Yoast support team what they need programmatically to display parent or child post information in the SEO metadata, I may be able to analyze that and provide some assistance to implement their code in a way that works with Types. I found their support forum here:
hidden link

#579182

Is there nothing in the parent post that links it to the child post?
That is to say, the child post contains _wpcf_belongs_parentslug_id field but the parent post doesn't contain a field linking it to its child. Am I understanding correctly?

#579209

Yes, that is correct. The parent relationship is established with a postmeta field only in the child post, not vice versa.

#581234

Thanks for the info. Since I need to get data in both directions (parent/child) I do not think a variable will work, as it sounds like it doesn't exist. I will follow up with Yoast to see how we can scrape the page to get the info that appears on the page into the meta description.

#1127665

I am continuing to have trouble with this. Because my webpages are built using Views, WordPress does not generate an auto excerpt, and I cannot set a meta description / og:description using content from the page. This affects search results and the page preview on things like Facebook. I feel like I must be missing something -- this shouldn't be so difficult. If the text on the page was in the content/WYSIWYG editor area, this wouldn't be a problem. Can someone please help me figure out how to get search engines and other tools to recognize Views content?

#1127666

I will start a new thread.