• Hi, in WP e-Commerce plug each product has a main window for a description and a separate window at the bottom for an Additional Description. Now, it looks like the SEO plug in does not take into the account the Additional Desription at all. For example the SEO Page Analysis showes me few red dots because it only reads the main desription window not reading the Additinal Descrition. In my case most of the good content with keywords etc. is in the Additional Desription space. Because the product type and structure I could not do it any other way and I know many other users have it the same way. It would be great if the SEO plug in could take all the product desription content into consideration, is there any way to do this? Thanks.

    http://wordpress.org/extend/plugins/wordpress-seo/

Viewing 11 replies - 1 through 11 (of 11 total)
  • I also use WPEC. One small fix is to add this small block of code to your theme’s functions.php:

    add_filter( 'wpseo_metadesc', 'wpsc_wpseo_meta_description', 99 );
    function wpsc_wpseo_meta_description( $description ) {
    	if ( wpsc_is_single_product() ) {
    		$description = substr( wpseo_strip_shortcode( strip_tags( get_the_content() ) ), 0, 155 );
    	}
    	return $description;
    }

    Which causes the meta description to be generated from the contents rather than the odd place WPEC opted to store additional stuff.

    I have some other small WPEC/WPSEO integration fixes. Once they’re more polished I plan to pack them into a small plugin that’ll allow others using both to have them play nice together.

    Thread Starter virage

    (@virage)

    Hi, Alexander I have added the code to functions.php but it did nothing as far as the Yoast SEO goes, at least I don’t see anything different in the SEO admin area.

    Ah, yes, true. That fix is for another problem, I had misunderstood your question. To see what it actually does, open the source code of a product page in which you use the additional description field, and look at its meta description. Try it without and with the fix and you’ll notice what’s wrong when it isn’t applied.

    Now about your actual problem, unfortunately there’s currently no easy “put it into functions.php” fix. I think it can be done by opening the wordpress-seo/admin/class-metabox.php file and changing line 987 from:

    @$dom->loadHTML( $post->post_content );

    to:

    @$dom->loadHTML( $post->post_content . ( !empty( trim( $post->post_excerpt ) ) ? ' ' . $post->post_excerpt : '' ) );

    But I haven’t tested it. Could you give it a try?

    EDIT: Added sanity check.

    PS.: The above line assumes you don’t use WordPress’ “excerpt” field (which is where WPEC stores its “additional description”) in posts and pages. If you do, then its their analysis that will be incorrect.

    Which is the problem with WPEC. Since it does stuff like this, properly integrating it with other plugins becomes a matter of carefully checking the context so that what we do doesn’t cause issues elsewhere, and the other way around.

    Joost, could you perchance add a filter there so that we can change the page body under analysis? Something like:

    @$dom->loadHTML( apply_filters( 'wpseo_page_analysis_content', $post->post_content, $post ) );

    Would help quite a lot!

    PPS @ virage: There are other places in the file that refer to $post->post_content, specifically lines 1033, 1360, 1365, 1603 and 1642, so maybe you’ll have to change all those to refer to $post->post_content . ( !empty( trim( $post->post_excerpt ) ) ? ' ' . $post->post_excerpt : '' ) instead (without changing whatever surrounds them though).

    And a PS to Joost: due to the above, let me rephrase my filter request to one of replacing the instances of $post->post_content (the ones that make sense) to apply_filters( 'wpseo_page_analysis_content', $post->post_content, $post ). 🙂

    Thanks!

    Thread Starter virage

    (@virage)

    I’m getting errors with those modifications, but thanks anyway Alexander. Maybe Joost will find the time to do something native in the plugin.

    Yep, I forgot that empty(trim(...)) doesn’t work, it should be strlen(trim(...))>0. Sorry about that.

    I’ve just tested this corrected version, changing all instances of:

    $post->post_content

    to:

    $post->post_content . ( ( strlen( trim( $post->post_excerpt ) ) > 0 ) ? ' ' . $post->post_excerpt : '' )

    and it works, at least in the detailed Page Analysis tab. The mini-analysis below the focus keyword in the General tab, however, doesn’t seem to show correct counts (mine shows 0 for everything if it’s a word appearing only the additional description), but that’s JavaScript-based, a language I know very little about.

    Thread Starter virage

    (@virage)

    I’ve tested it too and it does include the additional content in the Page Analysis, that’s an improvement at least for now, maybe we can get by without the java mini analysis. Thanks for help Alexander

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] WP e-Commerce additional description’ is closed to new replies.