Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] WP_Error using ct_desc?????

  • Most important, thanks for the great plugin and the all the work you put into all the posts about seo!

    Using the latest version of the plugin my site was giving 500 errors. I tracked it down to line 207 in wpseo_functions.php.

    The ‘get_the_terms’ call returns an array of taxonomy terms indexed by term_id, not 0 based. When the 0 based reference to the term_id is passed into the field function the WP_error happens and caused the 500 error. Changing the function from get_the_terms to wp_get_object_terms seems to fix the problem. If you want to see what is generated i’ll be pushing the fix to for testing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is what the code in my modified function looks like…

    if ( preg_match_all( '/%%ct_desc_([^%]+)?%%/u', $string, $matches, PREG_SET_ORDER ) ) {
    		global $post;
    		foreach ( $matches as $match ) {
    			$terms  = wp_get_object_terms( $post->ID, $match[ 1 ] );
    			if ( !is_wp_error($terms) ) {
    				$replace_with = empty($terms) ? '' :  get_term_field( 'description', $terms[ 0 ]->term_id, $match[ 1 ] );
    				$string = str_replace( $match[ 0 ], $replace_with , $string );

    thank you for building this – this actually did the trick for me.
    My other workaround was to // $terms and $string and for some reason that seemed to work as well.

    I’m not sure where the problem lies – as some of my attribute items have this issue – but since upgrading woocommerce the new ones seem to have an issue with YOASTS plugin

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] WP_Error using ct_desc?????’ is closed to new replies.