wp globus and post grid

Ticket for: Combo Blocks
0
wp globus and post grid 1
arathra
Nov 14, 2021 12:08 PM 1 Answers
Member Since Jul 2021
Subscribed Subscribe Not subscribe
Flag(0)

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!

2 Subscribers
wp globus and post grid 1
wp globus and post grid 3
Submit Answer
Please login to submit answer.
1 Answers
Sort By:
Best Answer
0
wp globus and post grid 4
PickPlugins
Dec 15, 2021
Flag(0)

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/

wp globus and post grid 5
arathra
- Dec 20, 2021 03:24 PM
Flag (0)
0

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!

wp globus and post grid 6
PickPlugins
- Dec 20, 2021 09:20 AM
Flag (0)
0

Sorry for late reply, i forget to mention you will need to remove the action first. there is an example on the documentation page at bottom “Override existing output”

wp globus and post grid 5
arathra
- Dec 16, 2021 08:03 PM
Flag (0)
0

Hi,

Thanks for that. It is a little closer but one small problem remains.

When I use this code:

—————-
add_action(‘post_grid_layout_element_excerpt’, ‘my_post_grid_layout_element_excerpt’);
function my_post_grid_layout_element_excerpt( $args ){

$element = isset($args[‘element’]) ? $args[‘element’] : array();
$elementIndex = isset($args[‘index’]) ? $args[‘index’] : ”;
$post_id = isset($args[‘post_id’]) ? $args[‘post_id’] : ”;
if(empty($post_id)) return;
$layout_id = isset($args[‘layout_id’]) ? $args[‘layout_id’] : ”;
$post_excerpt = ‘TEST: ‘ . get_the_excerpt( $post_id );
$post_link = get_permalink($post_id);
$link_target = isset($element[‘link_target’]) ? $element[‘link_target’] : ”;
$custom_class = isset($element[‘custom_class’]) ? $element[‘custom_class’] : ”;
$char_limit = isset($element[‘char_limit’]) ? (int) $element[‘char_limit’] : 0;
$read_more_text = isset($element[‘read_more_text’]) ? $element[‘read_more_text’] : __(‘Read more’, ‘post-grid’);

if( $char_limit > 0 ) {
$post_excerpt = wp_trim_words( $post_excerpt, $char_limit, ” );
}

?>
<div class="element element_ excerpt “>

<?php
}
———————

It displays the exact text I need in the right language. However, it doesn't remove the original excerpt which is displayed just under it.

You can see a screenshot of what I mean here: https://ibb.co/RBL7Zs8

The TEST is the text taken using the code above, but under that shows the excerpt again (which is showing in all languages). How can I get rid of the second excerpt?

Many thanks.

Sign in to Reply
Replying as Submit