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

Multiple Related Content Metaboxes WordPress

  • SOLVED

Working on a project that features a variety of related content... I ran across a very slick plugin that is very intuitive and easy to use called:

<strong>Related Links</strong>
by Triggvy Gunderson
[[LINK href="http://wordpress.org/extend/plugins/related-links/"]]http://wordpress.org/extend/plugins/related-links/[[/LINK]]

However, instead of pulling in all types of content into this feature (pages, posts, custom post types, etc) like this plugin does, I would like to create multiple instances of this plugin within the admin side where each instance focuses on a specific type of content.

For example, one instance pulling in only pages for a "Related Pages" section on the front-end... Another one instance pulling in a custom post type called "whitepaper" for a "Related Whitepapers" section on the front-end... This way I have more control over how these related items are displayed in the front-end, instead of listing all of these related items in the same list as the above plugin does.

I did a quick mockup to show how this plugin would look like in this scenario:
[[LINK href="http://swept.co/_dev/related-link-expanded.png"]]http://swept.co/_dev/related-link-expanded.png[[/LINK]]

<strong>OR</strong>, If someone can give me some insight in how to add a metabox that features a multi-select form that pulls in a specified type of content (for example, all pages only), and allows the user to select multiple pages from this section and display them in a list on the front-end ...

Any help would be greatly appreciated.

Answers (2)

2013-02-07

Naveen Chand answers:

Below code is an example of an instance which generates links in whitepapers custom post type.


<?php if(function_exists('get_related_links')) : ?>
<?php $related_links = get_related_links('whitepapers'); ?>
<ul>
<?php foreach ($related_links as $link): ?>
<li><a href="<?php echo $link['url']; ?>"><?php echo $link['type']; ?>: <?php echo $link['title']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>


You can add this code at different places in your page template or sidebar template files. Each time you add, just remember to give unique variable names to $related_links and $link.

This way you can generate any number of instances on the front-end.


Michael Brumm comments:

Thank you. Thank you. Thank you.

This will work just fine... I was making it overly complicated.


Michael Brumm comments:

Sorry, haven't used this system in awhile and wanted to give Naveen credit specifically...

Naveen Chand, you solved my problem without overly complicating things... I was unaware of this feature with this plugin... Again, many thanks.

2013-02-07

Kyle answers:

I can see you are looking for a very custom solution, but thought I would show this if you haven't seen it as a money saving solution :)

[[LINK href="http://codecanyon.net/item/better-related-posts-widget/427853?sso?WT.ac=search_item&WT.seg_1=search_item&WT.z_author=mordauk"]]http://codecanyon.net/item/better-related-posts-widget/427853?sso?WT.ac=search_item&WT.seg_1=search_item&WT.z_author=mordauk[[/LINK]]

You can choose any available taxonomy for each instance