Created
December 5, 2012 13:34
-
-
Save magadanskiuchen/4215541 to your computer and use it in GitHub Desktop.
Posts2Posts -- can't get connection title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
$connections = P2P_Connection_Type_Factory::get_all_instances(); | |
if (!empty($connections)) { | |
foreach ($connections as $type => $conn) { | |
p2p_connection_box($type, $conn, $post); | |
} | |
} | |
function p2p_connection_box($type, $conn, $post) { | |
$direction = false; | |
$opposite = false; | |
if ($conn->side['from']->query_vars['post_type'][0] == $post->post_type) { | |
$direction = 'from'; | |
$opposite = 'to'; | |
} else if ($conn->side['to']->query_vars['post_type'][0] == $post->post_type) { | |
$direction = 'to'; | |
$opposite = 'from'; | |
} | |
$opposite_post_type = $conn->side[$opposite]->query_vars['post_type'][0]; | |
if ($direction) { | |
?> | |
<li> | |
<h3 class="widgettitle"> | |
<?php | |
echo $conn->get_field('title', $direction); // empty string | |
// in version 1.4.2 I would get the box title using: | |
// echo $conn->title[$direction]; | |
?> | |
</h3> | |
<!-- some more markup goes here --> | |
</li> | |
<?php | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment