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.
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
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?
Yes, that is correct. The parent relationship is established with a postmeta field only in the child post, not vice versa.
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.
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?
I will start a new thread.