Skip Navigation

[Resolved] Meta descriptions / excerpts from Views content

This support ticket is created 6 years, 2 months 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)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1127667

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 what I'm doing wrong?

#1127740

Hi, Toolset provides some integration with Yoast, a popular SEO plugin, to help manage the SEO metadata associated with each post. You can expose custom field values to Yoast, which can improve your Yoast analysis results. Yoast also allows you to manipulate OG metadata on each post. We have some documentation about the integration between our systems available here: https://toolset.com/documentation/user-guides/seo-for-custom-fields-using-toolset-and-yoast-seo/

Let me know if I've misunderstood what you want to accomplish.

#1128389

Thanks for your response. I am already using the Yoast SEO plugin, and have reviewed all of my custom fields to ensure they are wrapped in appropriate HTML tags. My issue is with Toolset relationships.

Here's an example of how a webpage is built on my site:
Each page is a Journal (custom post type), containing:
H1 Journal title
H2 Article title (article is a post type that is a child of Journal using Toolset relationship)
P Article body (from standard wysiwyg)

My problem is that because the majority of the content on the page is coming from a child post (Article), Yoast / search engines / FB scraper / etc. aren't reading the content.

#1128477

I see what you mean, thanks. Yoast isn't designed to dig into the Content Templates and Views associated with each post, and allow you to access that information in metadata. Yoast does offer snippet variables (https://yoast.com/snippet-variables/), but they only relate to information associated with the current post (not related posts or View results). The only solution I can think of right now is to create custom Yoast snippet variables using PHP: http://hookr.io/functions/wpseo_register_var_replacement/

With our Views APIs (https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results) and Types APIs (https://toolset.com/documentation/customizing-sites-using-php/functions/), you could add information from any View into any of the Yoast fields for a post using this custom snippet variable.

For example, let's say you have a Journal post that includes View 12345, which shows this Journal's child Articles. You want to include the excerpt of the 1st result of the View in the Yoast Facebook description field. You can do that with a custom snippet variable:

// define the custom replacement callback
function get_first_result_excerpt_12345() {
  global $post, $current_user;
  $args = array( 'limit' => 1 );
  $articles = get_view_query_results( 12345, $post->ID, $current_user->ID, $args);
  $excerpt = isset($articles[0]) ? get_the_excerpt($articles[0]) : '';
  return $excerpt;
}

// define the action for register yoast_variable replacments
function register_custom_yoast_variables() {
    wpseo_register_var_replacement( '%%firstarticleexcerpt%%', 'get_first_result_excerpt_12345', 'basic', 'First Article Excerpt' );
}

// Add action
add_action('wpseo_register_extra_replacements', 'register_custom_yoast_variables');

Then use the snippet variable %%firstarticleexcerpt%% in the Facebook description field for this post (or any Journal post that uses this same View). The Yoast panel will show the variable like '%%firstarticleexcerpt' but the actual post will include the correct information from the first result in the View.

#1132145

Thanks for the detailed information and custom snippet example. I'll go through this with my developer and decide whether or not we want to proceed with this direction. I truly wish this was simpler -- I wouldn't have used Toolset relationships to build these pages had I known I'd have these issues.

#1132215

I'll stand by for your update. No need to reply right now, the ticket will remain open for 30 days.