This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 3 voices.

Last updated by steffenL 4 years, 5 months ago.

Assigned support staff: Dat Hoang.

Author Posts
February 11, 2015 at 3:00 pm #558966

steffenL

I am trying to: get translated excerpts on custom post type blog page.

I visited this URL: hidden link

I expected to see: translated excerpts in English an German.

Instead, I got: excerpts in Dansk (main language) only.

February 12, 2015 at 6:50 am #559360

Dat Hoang

Your WPML and its add-on versions are up-to-date.

#1,
Which plugin/theme creates the custom post type?
Or you create it by your own code? If so, please let me know your code.

#2,
What is the code that creates "auto excerpt"?

February 13, 2015 at 10:07 am #560257

steffenL

Hi, thanks for reply.

I created it by my own code.

Code #1:

//Custom Post Type Bands
if ( ! function_exists('bands_custom_post_type') ) {

// Register Custom Post Type
	function bands_custom_post_type() {

		$labels = array(
			'name'                => 'Kunstnere',
			'singular_name'       => 'Kunstner',
			'menu_name'           => 'Kunstnere',
			'parent_item_colon'   => 'Parent Item:',
			'all_items'           => 'All Items',
			'view_item'           => 'View Item',
			'add_new_item'        => 'Add New Kunstner',
			'add_new'             => 'Add New',
			'edit_item'           => 'Edit Item',
			'update_item'         => 'Update Item',
			'search_items'        => 'Search Item',
			'not_found'           => 'Not found',
			'not_found_in_trash'  => 'Not found in Trash',
		);
		$args = array(
			'labels'              => $labels,
			'supports'            => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', ),
			'taxonomies'          => array( 'post_tag' ),
			'hierarchical'        => false,
			'public'              => true,
			'show_ui'             => true,
			'show_in_menu'        => true,
			'show_in_nav_menus'   => true,
			'show_in_admin_bar'   => true,
			'menu_position'       => 5,
			'menu_icon'           => 'dashicons-format-audio',
			'can_export'          => true,
			'has_archive'         => true,
			'exclude_from_search' => false,
			'publicly_queryable'  => true,
			'capability_type'     => 'page',
		);
		register_post_type( 'bands', $args );

	}

// Hook into the 'init' action
	add_action( 'init', 'bands_custom_post_type', 0 );

}

Code #2:

// WP_Query arguments
$args = array (
	'post_type'              => 'bands',
	'pagination'             => true,
	'posts_per_page'         => '100',
	'order'                  => 'ASC',
	'orderby'                => 'title',
);

// The Query
$query = new WP_Query( $args );

<div id="content" style="<?php echo $content_css; ?>">
		<?php if ( $query->have_posts() ) {
			while ( $query->have_posts() ) {
				$query->the_post();
					$page_id = get_the_ID(); ?>

					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						<?php echo avada_render_rich_snippets_for_pages(); ?>
						<a href="<?php the_permalink(); ?>">
							<?php the_post_thumbnail(); ?>
						</a>
						<h4 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
						<div class="post-content">
							<?php the_excerpt(); ?>
							<?php avada_link_pages(); ?>
						</div>
						<?php if( ! post_password_required($post->ID) ): ?>
						<?php if($smof_data['comments_pages']): ?>
							<?php
							wp_reset_query();
							comments_template();
							?>
						<?php endif; ?>
						<?php endif; ?>
					</div>
					<?php }
			}
		// Restore original Post Data
		wp_reset_postdata(); ?>
	</div>
February 16, 2015 at 3:05 pm #561491

Robert

Dat is away so I will help in his place.

Unfortunately, customizing the theme is outside of support so if this is desired please feel free to contact one of our certified partners: http://wpml.org/documentation/support/wpml-contractors/

Having said that, I think the problem is that the language of the ID is not taken into account. Please review this page: http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/ and also http://wpml.org/documentation/support/wpml-coding-api/

February 17, 2015 at 9:38 am #561907

steffenL

Thank you Robert!