Support » Plugin: WP-PostRatings » Play Nicer with Yoast SEO

  • Yoast SEO (one of the most popular SEO plugins) can have alternate titles which are used for SEO which differ from the page title. A page title of “Widgets” which is short and easy to display may have a really nice SEO title which we want in search engines. If enabled, we should really use that instead of the short title, as that way the SEO title displays. Similarly, a SEO meta description can also be used which again, should show in the rich snippet. this also makes it consistent with the rich snippets for the page itself such as if it’s a blog/review/product/etc. I provide a patch below.

    — wp-postratings.bak 2018-12-26 05:12:00.000000000 -0500
    +++ wp-postratings.php 2019-01-08 13:27:13.297672478 -0500
    @@ -1163,7 +1163,12 @@

    // Post Template Variables
    $post_link = get_permalink( $post_data );
    – $post_title = get_the_title( $post_data );
    + //$post_title = get_the_title( $post_data );
    + if ((get_post_meta($post->ID, ‘_yoast_wpseo_title’, true)) == “”) {
    + $post_title = get_the_title($post_data);
    + } else {
    + $post_title = get_post_meta($post_id, ‘_yoast_wpseo_title’, true);
    + }
    if ( $max_post_title_chars > 0 ) {
    $post_title = snippet_text( $post_title, $max_post_title_chars );
    }
    @@ -1197,6 +1202,10 @@
    $value = str_replace( ‘%POST_THUMBNAIL%’, get_the_post_thumbnail( $post, ‘thumbnail’ ), $value );
    }

    + if (get_post_meta(get_the_ID(), ‘_yoast_wpseo_metadesc’, true) <> “”) {
    + $post_excerpt = get_post_meta(get_the_ID(), ‘_yoast_wpseo_metadesc’, true);
    + }
    +
    // Google Rich Snippet
    $google_structured_data = ”;
    $ratings_options[‘richsnippet’] = isset( $ratings_options[‘richsnippet’] ) ? $ratings_options[‘richsnippet’] : 1;

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.