I'm able to deploy the duplicator of the site on my local test server. I can see with the duplicator you shared it is using the Toolset Types plugin version 3.3.7.
The Types plugin version 3.3.7 is after new post relationship is implemented.
I would like to know that:
- Are you trying to update the Types plugin from 3.3.7 to 3.4.17 and you are facing the issues?
- What exact steps I should follow to see the issue?
- Do I require SQL file that holds the old post relationship (pre Types 3.0.x) ? If yes, where can I get that SQL file that holds old post relationship?
- Are you trying to update the Types plugin from 3.3.7 to 3.4.17 and you are facing the issues?
Yes exactly, once the plugin is updated and I run the Database migration suggested in plugin, I face the issues.
- What exact steps I should follow to see the issue?
Update the plugin
Migrate the database.
Search for an author name in site search, you will notice that search results do not contain posts of that author.
- Do I require SQL file that holds the old post relationship (pre Types 3.0.x) ? If yes, where can I get that SQL file that holds old post relationship?
Nope I don't think so, as the plugin version 3.3.7 is working fine for me, it's only after the update and migration the issue occurs.
After debugging too much I found the cause of the issue.
The issue was from the custom code you added to your child theme's search.php file where you are trying to fetch the related child post IDs. You should always use the Toolset post relationship API to fetch the related posts using the specified functions.
The custom code you added to your child theme's search.php file was here:
global $wpdb;
$author_posts = $wpdb->get_results(
$wpdb->prepare( "SELECT child_id FROM {$wpdb->prefix}toolset_associations WHERE parent_id=%d", $authorID )
);
$posts_in = array();
foreach( $author_posts as $ap ) {
$posts_in[] = intval( $ap->child_id );
}
- currently I've commented the above code with your theme's search.php file
I've replaced the above code with the following code with your search.php file available with your child theme:
=> themes/generatepress_child/search.php
$author_posts = toolset_get_related_posts(
$authorID, //Post to query by.
'article-authors', //Slug of the relationship to query by
'parent', //Name of the element role to query by.
999, //Maximum number of returned results
0, //Result offset
array( //Additional query arguments
),
'post_id', //Determines return type
'child', // which posts from the relationship should be returned
);
$posts_in = array();
foreach( $author_posts as $ap ) {
$posts_in[] = intval( $ap);
}
Now we can see the correct results:
=> hidden link
Thank you Minesh, It seems that the issue is fixed. I am still testing the complete website for any remaining issues. Will update here in a day or two.