-
Notifications
You must be signed in to change notification settings - Fork 0
Get Started
Igor Tron edited this page Apr 15, 2023
·
3 revisions
Add the package
composer require hokoo/wpconnectionsSo, you have to create client instance...
use iTRON\wpConnections\Client;
$wpc_client = new Client( 'my-app-wpc-client' );...and relations for your connections.
use iTRON\wpConnections\Query;
$qr = new Query\Relation();
$qr->set( 'name', 'post-to-page' );
$qr->set( 'from', 'post' );
$qr->set( 'to', 'page' );
$qr->set( 'cardinality', 'm-m' );
$wpc_client->registerRelation( $qr );Ok, now you can create connections inside the relation.
$qc = new Query\Connection();
$qc->set( 'from', $post_id_from );
$qc->set( 'to', $post_id_to );
$wpc_client->getRelation( 'post-to-page' )->createConnection( $qc );