Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Acquiring metabox values from "Related Links" plugin WordPress

  • SOLVED

I've posted a question for the developer of this plugin that's gone unanswered and am looking for some insights on how to extend this plugin to achieve the desired effect.

Related Links Plugin:
[[LINK href="http://wordpress.org/extend/plugins/related-links/"]]http://wordpress.org/extend/plugins/related-links/[[/LINK]]

I have a scenario where I would like to insert the URL from a meta box instead of inserting the permalink.

<?php if(function_exists('get_related_links')) : ?>
<?php
$related_displayfiles = get_related_links('displayfile');
// If no related content exists, use related links from parent
if(count($related_displayfiles) == 0){
$related_displayfiles = get_related_links('displayfile', $whichparent);
} ?>
<ul>
<?php foreach ($related_displayfiles as $rdisplayfile): ?>
<li><a href="<?php echo $rdisplayfile['url']; ?>"><?php echo $rdisplayfile['title']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>


Like I mentioned above, instead of echoing the permalink like this below...
echo $rdisplayfile['url'];

... I'd like to echo the value from a meta box (called metaboxurl in this example):
echo $rdisplayfile['metaboxurl'];

Any ideas?

Answers (2)

2013-04-02

Aneesh Joseph answers:

... try using
echo get_post_meta($rdisplayfile['id'], 'metaboxurl', true)


Michael Brumm comments:

Forgot about get_post_meta... Thanks for the reminder... Worked perfectly.

2013-04-02

Arnav Joy answers:

<?php if(function_exists('get_related_links')) : ?>

<?php

$related_displayfiles = get_related_links('displayfile');

// If no related content exists, use related links from parent

if(count($related_displayfiles) == 0){

$related_displayfiles = get_related_links('displayfile', $whichparent);

} ?>

<ul>

<?php foreach ($related_displayfiles as $rdisplayfile): ?>
<?php $meta_url = get_post_meta($rdisplayfile['id'], 'metaboxurl', true);?>
<li><a href="<?php echo $meta_url ; ?>"><?php echo $rdisplayfile['title']; ?></a></li>

<?php endforeach; ?>

</ul>

<?php endif; ?>

// change name of the meta field "metaboxurl"


Michael Brumm comments:

Forgot about get_post_meta... Thanks for the reminder... Worked perfectly.