Skip Navigation

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 2 replies, has 2 voices.

Last updated by henrikR-17 1 year, 10 months ago.

Assisted by: Long Nguyen.

Author Posts
March 14, 2023 at 7:56 pm #13246329

henrikR-17

Hi!

WP has a very strange functionality:
When I write a manual excerpt for a Post, the "Read more"-link for that Post, on the Blog-page, is removed by WP. This does not make any sense for me, so I have to recreate it with a code snippet.
Astra Pro support gave me the code below, but it is not multilingual... Can you help me repair this dysfunctionality of WP?
I am using WPCode to insert this code snippet:

//* Display read more when excerpt is added.*//
function new_excerpt_more($more) {
return '';
}
add_filter('excerpt_more', 'new_excerpt_more', 21 );
function the_excerpt_more_link( $excerpt ){
$post = get_post();
$excerpt .= '<p class="read-more">ID) . '">Read more »</p>';
return $excerpt;
}
add_filter( 'the_excerpt', 'the_excerpt_more_link', 21 );

Note: I would also like to change it to a button.

I have attached a screen shot from before I added the code snippet above. There you can see that WP has removed the "Read more"-link on a manual excerpt.

I have not provided WPML debug info. I don't see the point. 🙂

Astra manual excerpt no 'read more' button.png
March 15, 2023 at 4:57 am #13248045

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Henrik,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

You need to wrap the string in a WordPress localization function like __() or _e() to make the string translatable. For example:

$excerpt .= '<p class="read-more"><a href="'. get_permalink($post->ID) . '">' . __( 'Read more "', 'your-text-domain' ) . '</a></p>';

Then you can go to WPML > Theme and plugins localization > Scan for the strings in the theme or plugin and translate the string in WPML > String Translation.

Please read more on the documentation https://developer.wordpress.org/themes/functionality/internationalization/
https://wpml.org/documentation/getting-started-guide/string-translation/
or refer to this sample code https://developer.wordpress.org/reference/hooks/excerpt_more/#comment-content-2054

I would like to inform you that helping you with custom code, is out of the scope of WPML. If you are not able to accomplish this, I would recommend you contact one of our certified partners that will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/

Look forward to your reply.
Thanks

March 15, 2023 at 9:33 am #13249517

henrikR-17

I understand that this is a WP problem and not a WPML problem. Unfortunately I have the 'small' WPML Blog, where WPML String Translation is not included. So I will have to live with the lack of logic among WP developers... I have reported the problem here: https://core.trac.wordpress.org/ticket/57909