Skip Navigation

[Resolved] Display view content with The Grid Plugin – part 2

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 10 replies, has 2 voices.

Last updated by marcJ 5 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1153796
Capture d’écran 2018-11-27 à 16.01.46.png

Hi, Sorry for open another ticket but our previous ticket was close (Maybe you can merge the two..)

so the previous ticket is : https://toolset.com/forums/topic/display-view-content-with-the-grid-plugin/

The code you provided to me work, I'm able to display the latest post form the "Thematique" I'm in. But it display only the first latest post. I want my grid to display the right number of post accordingly to the number I set on Plugin settings.

#1153861

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You used the code (edited as required) from this previous reply, is that correct?

https://toolset.com/forums/topic/display-view-content-with-the-grid-plugin/#post-1124376

In that sample I added some error_log calls to help with debugging.

When you visit a thematique post (which is supposed to show the related standard posts), what do you see in your debug.log?

(If you deleted those error_log calls, add back the error_log call for related posts to be able to see what is returned by the relationships API call.)

#1153877

Yes I used and edited the code you provided me on the previous reply. Her my debug.log file :
Maybe you understand something... Not me..

[27-Nov-2018 12:51:24 UTC] $post: WP_Post Object
(
    [ID] => 384727
    [post_author] => 1
    [post_date] => 2018-11-27 11:15:05
    [post_date_gmt] => 2018-11-27 11:15:05
    [post_content] => 
    [post_title] => Overwatch
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => closed
    [ping_status] => closed
    [post_password] => 
    [post_name] => overwatch
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2018-11-27 11:15:05
    [post_modified_gmt] => 2018-11-27 11:15:05
    [post_content_filtered] => 
    [post_parent] => 384608
    [guid] => <em><u>hidden link</u></em>
    [menu_order] => 0
    [post_type] => browser
    [post_mime_type] => 
    [comment_count] => 0
    [filter] => raw
)

[27-Nov-2018 12:51:24 UTC] related_posts: Array
(
    [0] => 383147
)
#1153880

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Thanks for sharing that.

That confirms that the thematique post you are displaying only has a single post (ID = 383147) connected to it, which is why only one post is being displayed, regardless of the setting for how many posts the grid should display. There is only one post to display.

If you connect more posts to that same thematique post, then you should see more results in the grid.

#1153885
Capture d’écran 2018-11-27 à 17.12.27.png
Capture d’écran 2018-11-27 à 17.12.52.png

Yes I understand what you say and this is the problem I have connected 3 post for my test, like I show you on my screenshot, and on the front end it display only the latest.

Maybe I have connected post on a bad way ? I don't know.

#1153957

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Can I take a look at your site myself?

I may need to install one or two plugins to help with debugging, but I won't otherwise make any changes.

Be sure to have a current back up, though.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete.

#1153996

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Where did you add the custom code that filters the query used by the grid plugin?

I was looking for it in Toolset > Settings > Custom Code. If you added it to the theme I'm unable to edit the theme files from within WP admin.

Could you move the code from where you have it and add it as a custom code snippet on the above page?

#1154004

By custom code you mean this :

function my_query_args($query_args, $grid_name) {
  
    if ($grid_name == 'Male') {
 
        global $post;
        error_log('$post: ' . print_r($post, true));
 
        $related_posts = toolset_get_related_posts( $post->ID, 'rel_boardpost', 'parent', array( 'limit' => 999, 'return' => 'post_id', 'role_name_to_return' => 'other' ) );
        error_log('related_posts: ' . print_r($related_posts, true));
 
        $query_args['post__in'] = $related_posts;
    }
      
    return $query_args;
      
}
add_filter('tg_wp_query_args', 'my_query_args', 10, 2);

is on my functions.php

if you mean the custom code to display the grid is on elementor -> template -> "Section Template"

#1154429

Hi,

I didn't know this features from toolset and is awesome. I moved the code from functions.php to Toolset > Settings > Custom Code

But the problem is not yet solved.

#1154598

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I checked your site and everything seemed set up correctly, but then testing the toolset_get_related_posts hook on my own local test site I realised that one of the parameters was provided incorrectly, which is why only one post was being returned.

I fixed the code on your site, and it is now working correctly.

#1154677

Really Nice Thank you very much for your awesome support.