Skip to content

Instantly share code, notes, and snippets.

@magadanskiuchen
Created December 5, 2012 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magadanskiuchen/4215541 to your computer and use it in GitHub Desktop.
Save magadanskiuchen/4215541 to your computer and use it in GitHub Desktop.
Posts2Posts -- can't get connection title
<?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