We use WP Globus translation software extensively on our site, along with the Pro version of Post Grid.
When Post Grid gets the each grid block it gets the title of the page in the right language, but it doesn't filter the extract of the page in the right language.
So, for example, on an English page it shows:
This is the Page Title
{:en}And this is English content.{:}{:it}E questo è contenuto in italiano{:}
And on the Italian page it shows:
Questo è il titolo della pagina
{:en}And this is English content.{:}{:it}E questo è contenuto in italiano{:}
So the title is shown correctly, but not the extract.
We need to be able to filter the extract of the page so that it shows the right language extract and not just the plain text.
Is there a hook or way we can filter the extract before it is displayed?
Many thanks!
Welcome to our forum.
Sorry for late reply, unfortunately, we haven't tested with wp globus,
there is an action hook for each element on grid, like post title, thumbnail, excerpt and etc.
please check this to filter the excerpt
https://pickplugins.com/documentation/post-grid/action-hooks/post_grid_layout_element_id/
All elements
https://pickplugins.com/documentation/post-grid/elements/
Hi, thanks for that.
I tried adding this:
remove_action(‘post_grid_layout_element_excerpt’, ‘post_grid_layout_element_excerpt’);
add_action(‘post_grid_layout_element_excerpt’, ‘post_grid_layout_element_excerpt_custom’);
function post_grid_layout_element_excerpt_custom( $args ){
// my code
}
But it would still display the info gathered in post_grid_layout_element_excerpt. In other words, the remove_action isn’t working for me.
For now I’ve hacked the core code (not ideal obviously!) on post-grid-layout-elements.php around line 1807 to have
$post_excerpt = get_the_excerpt( $post_id );
if( $char_limit > 0 ) {
$post_excerpt = wp_trim_words( $post_excerpt, $char_limit, ” ) . ‘…’;
}
But again, this is obviously only a temporary solution.
Am I missing something in trying to remove the action? I have this in my plugin code, btw.
Many thanks!