Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter alex00shu

    (@alex00shu)

    Thank you, Sybre. Indeed I added a page to my CPTA, shouldn’t do that.

    I also found your filter for polylang and changed it a bit, so that it can work with WPML

    // Translate WPML activity post type meta
    add_filter( 'the_seo_framework_post_type_archive_meta', 'my_custom_seo_framework_post_type_archive_meta', 10, 2 );
    /**
    
     *
     * @param array  $meta      The current post type archive meta : {
     *    'doctitle'           => string
     *    'title_no_blog_name' => int
     *    'description'        => string
     *    'og_title'           => string
     *    'og_description'     => string
     *    'tw_title'           => string
     *    'tw_description'     => string
     *    'social_image_url'   => string
     *    'social_image_id'    => int
     *    'canonical'          => string
     *    'noindex'            => int
     *    'nofollow'           => int
     *    'noarchive'          => int
     *    'redirect'           => string
     * }
     * @param string $post_type The current post type.
     * @return array $meta The post type archive metadata for TSF.
     */
    function my_custom_seo_framework_post_type_archive_meta( $meta, $post_type ) {
    
    
      $my_current_lang = apply_filters( 'wpml_current_language', NULL );
    
    	if ( empty($my_current_lang) ) return $meta;
    	// Bail if 'news' isn't the post type.
    	if ( 'news' !== $post_type ) return $meta;
    
    	switch ($my_current_lang) {
    		case 'en':
    			$meta['doctitle']       = "English Document Title";
    			$meta['description']    = "English Description";
    			$meta['og_title']       = "English Open Graph Title";
    			$meta['og_description'] = "English Open Graph Description";
    			$meta['tw_title']       = "English Twitter Title";
    			$meta['tw_description'] = "English Twitter Description";
    			break;
    		case 'ru':
    			$meta['doctitle']       = "German Document Title";
    			$meta['description']    = "German Description";
    			$meta['og_title']       = "German Open Graph Title";
    			$meta['og_description'] = "German Open Graph Description";
    			$meta['tw_title']       = "German Twitter Title";
    			$meta['tw_description'] = "German Twitter Description";
    			break;
    	}
    
    	return $meta;
    }

    Seems to be working

    • This reply was modified 1 year ago by alex00shu.
    Thread Starter alex00shu

    (@alex00shu)

    Thank you!

    Thread Starter alex00shu

    (@alex00shu)

    I figured it out, that was my mistake with custom post types.

    Thread Starter alex00shu

    (@alex00shu)

    Ok, thanks

Viewing 4 replies - 1 through 4 (of 4 total)