Hi,
I want to assign related child posts to parent post by code but as you are not using postmeta to save the parent-child relationship. I have checked the database and found that you have created the custom table to manage the relationship. Is there any function or hook by which I can assign the child Posts. Thanks in Advance.
Hi, we offer the new Post Relationships API toolset_connect_posts just for this situation. You can find the documentation for all the Post Relationships APIs here: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
Let me know if you get stuck implementing this and I can offer some guidance.
Hi Christian,
Thanks for the reply, I am adding this toolset_connect_posts( 'client-project', 12808,12811 ) function in my plugin but it's not working. Is there any global variable or anything else that should I need to include in my plugin file for the proper working of toolset function.
No, there are no additional include files required for this functionality. You should not call this code before Toolset is fully loaded and initialized. Please see the remarks about timing here:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#remarks
If you are having trouble, please turn on server logs and let me know if any errors appear. If you're not familiar with server logs, I can show you how to activate them temporarily. Go in your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:
define('WP_DEBUG', true);
Then add these lines, just before it says 'stop editing here':
ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
Then trigger this code again. If any errors are thrown, an error_log.txt file will appear in your site's root directory. Please send me its contents. Once that is done, you can revert the changes you made to wp-config.php.