Cornerstone Dynamic Content - Incorrect post ID used in the "generate_seo_data" function for use in excerpt and og:description

We use dynamic content on all pages and posts to pull in the post / page title, and on posts an extra ACF field of ‘subtitle’, and use that for the heading at the top of the page.

This works great in the page editor and on the front-end, but in the generated og:description, it is pulling the post title and ACF data from different posts. Have noticed that this is showing up inside the [cs_content_seo] shortcode generated within the post content which gets used for generating the excerpt / og:description.

For example, this post: https://connexxions.me/2020/01/ben-mowat-photography-studio-recording-session/
The post title is “Ben Mowat” and the ACF field ‘subtitle’ is “Studio recording session”, but in the og:description meta, and in the [cs_content_seo] shortcode, it is being pulled in from a different post: “Sust!:health retreat logo design Brand identity, Graphics & Illustration show text hide text Commissioned photoshoot of a studio recording session for”

Looking at this output, it looks like a deeper issue of global $post not being the correct current post when generating the content for [cs_content_seo], as there is also a custom element here which displays the taxonomies of the current post, which for the “Ben Mowat” post should be “Photography”, but in the og:description meta / [cs_content_seo] is showing up as “Brand identity, Graphics & illustration”, which is being taken from the other post (“Sust!”)

I would be grateful for some assistance in getting to the bottom of this issue
Thanks

Hi @arthurodb,

Thanks for reaching out.

Any text you display on a post will become the excerpt, the [cs_content_seo] is just the output of overall text content. And even without that, it would still the same since do_shortcode() will execute it them including dynamic content.

In short, even if your Dynamic Content is coming from another post, and you placed it on that post, those content will become the visible content of it, and something the search engine that can see. Dynamic contents are executed on server through PHP, once it’s executed, there is no distinction which is Dynamic Content or not anymore. The search Engine will see it as single content.

What I can suggest is using manual excerpt, that is Wordpress feature that allows user to override any generated excerpt. Please check this https://www.wpbeginner.com/glossary/excerpt/

Or you can install any SEO plugin that allows you to override OG and meta data.

Thanks!

Hi @rad

Sorry, perhaps I wasn’t clear in my initial post. The issue is that Dynamic Content is coming up differently in the [cs_content_seo] section, compared with the front-end page. This is leading to other issues down the line as the content of the [cs_content_seo] section is used by WordPress to generate the excerpt. When inserting the Dynamic Content, I am not referring to a specific post ID, as I want the current post’s data to be read and inserted.

I have attached some screenshots to demonstrate this difference happening.

This is the Dynamic Content codes being used in the subtitle field:
image

And this is the output on the page itself, as it should be:
image

However, this is how that content is ending up within the [cs_content_seo] block in the WordPress edit post page:
image

You can see there that the post id now being referenced is 1778, which in turn is bringing in the wrong title (‘Sust!’ instead of ‘Ben Mowat’) and subtitle (‘health retreat logo design’ instead of ‘Studio recording session’)

This looks like a bug in the code that is generating the [cs_content_seo] block as it is pulling in the overall text, but using the wrong $post element to grab the title, ID, and custom fields from.

Are you able to replicate this issue and help with a solution?

Cheers

Hey @arthurodb,

I did the setup you showed us in my test sites and the [cs_content_seo] outputs the correct Dynamic Content. This means that there could be something else causing the issue on your site. With that said, please do the following troubleshooting procedures first to narrow down where the issue is coming from. Check if the issue persists after each step.

  1. TESTING FOR THEME RELATED ISSUE
  2. TESTING FOR PLUGIN CONFLICT
  3. THEME UPDATE
  4. CHILD THEME
  5. VERSION COMPATIBILITY

Only if none of that helps, please give us the following info in a Secure Note.

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts.

Thanks.

Hi there,

That’s odd that you are unable to recreate the issue. I have just set up a fresh install of WordPress and Pro with just one plugin installed and active (theme.co’s Maintenance plugin to hide the website) and I am still having the issue.

I have added the login url and account details to this reply securely so that you can go in and take a look.

I have set up a blank page with a headline in it that simply has the content: Page ID: {{dc:post:id}} in it.
The page ID is 5, as shown in the cornerstone editor URL, and on the front end of the site. However in the backend, it is still coming up incorrectly, and the WordPress editor content is [cs_content][cs_element_section _id="1" ][cs_element_layout_row _id="2" ][cs_element_layout_column _id="3" ][cs_element_headline _id="4" ][/cs_element_layout_column][/cs_element_layout_row][/cs_element_section][/cs_content]**[cs_content_seo]Page ID: 1[/cs_content_seo]**

Hey @arthurodb,

I see the issue on your site and my bad that I incorrectly tested previously. I was also using the ID of the post like this:

image

I’ve replicated the issue now so I’ll post this in our issue tracker. For now, please a specific ID or as Rad suggested, use the Manual Excerpt and find a plugin where you can manually set the Open Graph Description.

Thanks.

Great, glad that you were able to replicate the issue.

I will go and make the changes to the Dynamic Content for now whilst the fix is being worked on.

When the fix is found, is there a way to quickly regenerate all [cs_content_seo] content for all posts without going in to Cornerstone and saving each post again? If my understanding is correct, the [cs_content_seo] is generated when Cornerstone is saved, so to ensure the correct post ID is used in the Dynamic Content, when the fix is implemented, it will be necessary to re-save each post to regenerate that content, which will be tedious and time-consuming even for the 65 posts we have on our primary site! Any advice on how to speed this process up would be great. Perhaps a code snippet that could run through all Cornerstone content and regenerate the [cs_content_seo] content?

Cheers for your help so far

I believe it should pull data up automatically but if not, you need to resave the posts.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.