{"id":12775,"date":"2011-04-06T17:57:37","date_gmt":"2011-04-06T17:57:37","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/related-links\/"},"modified":"2012-09-12T09:15:04","modified_gmt":"2012-09-12T09:15:04","slug":"related-links","status":"publish","type":"plugin","link":"https:\/\/tah.wordpress.org\/plugins\/related-links\/","author":7783787,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.7.1","stable_tag":"trunk","tested":"3.4.2","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Related Links","header_author":"Triggvy Gunderson","header_description":"","assets_banners_color":"","last_updated":"2012-09-12 09:15:04","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/wordpress.org\/extend\/plugins\/related-links\/","header_plugin_uri":"http:\/\/wordpress.org\/extend\/plugins\/related-links\/","header_author_uri":"http:\/\/wordpress.org\/extend\/plugins\/related-links\/","rating":4.3,"author_block_rating":0,"active_installs":200,"downloads":19419,"num_ratings":6,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":"1","4":"2","5":"3"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.7","1.7.1"],"block_files":[],"assets_screenshots":{"screenshot-2.jpg":{"filename":"screenshot-2.jpg","revision":"1538855","resolution":"2","location":"plugin"},"screenshot-1.jpg":{"filename":"screenshot-1.jpg","revision":"1538855","resolution":"1","location":"plugin"}},"screenshots":{"1":"Related links Metabox on the post page.","2":"Settings page."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[14502,10584,537,86,2663],"plugin_category":[],"plugin_contributors":[81176],"plugin_business_model":[],"class_list":["post-12775","plugin","type-plugin","status-publish","hentry","plugin_tags-deep","plugin_tags-internal","plugin_tags-link","plugin_tags-post","plugin_tags-related","plugin_contributors-chabis","plugin_committers-chabis"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/related-links.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/related-links\/trunk\/screenshot-1.jpg?rev=1538855","caption":"Related links Metabox on the post page."},{"src":"https:\/\/ps.w.org\/related-links\/trunk\/screenshot-2.jpg?rev=1538855","caption":"Settings page."}],"raw_content":"<!--section=description-->\n<p>Related Links gives you the possibility to manually link other posts to your current post. But you can also link pages, media or any custom post-type. And in addition you can use custom urls to link to external files. The plugin adds a Metabox to the writing page with a list of all available content.<\/p>\n\n<p>Features:<\/p>\n\n<ul>\n<li>Shows a list of all available content in a Metabox on the writing page<\/li>\n<li>Multiple links can be selected<\/li>\n<li>Link order can be changed through drag and drop<\/li>\n<li>Custom URLs can be added<\/li>\n<li>Search field to quickly find a link<\/li>\n<li>Simple theme integration with an included widget or <code>related_links()<\/code><\/li>\n<li>Works with custom post-types<\/li>\n<li>Settings to enable the post-types that should be shown in the Metabox<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>related-links<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin through the <code>Plugins<\/code> menu in WordPress.<\/li>\n<li>Set in the link types in <code>Related Links<\/code> under the <code>Settings<\/code> menu in WordPress.<\/li>\n<li>Place <code>&lt;?php related_links(); ?&gt;<\/code> in your templates.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>How do I show the links in my theme?<\/dt>\n<dd><p>Use the <code>Related Links<\/code> widget to show a list of the related links.<\/p><\/dd>\n<dt>How do I show the links in a specific template?<\/dt>\n<dd><p>Use the <code>related_links()<\/code> function directly in your template files. This will return an unordered list with an <code>&lt;ul&gt;<\/code> wrapper. Use this code for example in your `content.php' template:<\/p>\n\n<pre><code>&lt;?php related_links(); ?&gt;\n<\/code><\/pre><\/dd>\n<dt>How can I modify the output of the link list?<\/dt>\n<dd><p>You need to use the <code>get_related_links()<\/code> function. A simple example that shows a list with all link names and the type of link:<\/p>\n\n<pre><code>&lt;?php $related_links = get_related_links(); ?&gt;\n&lt;ul&gt;\n    &lt;?php foreach ($related_links as $link): ?&gt;\n        &lt;li&gt;&lt;a href=\"&lt;?php echo $link['url']; ?&gt;\"&gt;&lt;?php echo $link['type']; ?&gt;: &lt;?php echo $link['title']; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n    &lt;?php endforeach; ?&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><\/dd>\n<dt>What are the properties returned by the `get_related_links()` function?<\/dt>\n<dd><p>The <code>get_related_links()<\/code> returns an array containing every related link. when you loop through this array every link consists of another array with the following keys:<\/p>\n\n<ul>\n<li>key <code>id<\/code>: equals to <code>$post-&gt;ID<\/code> or <code>null<\/code> for custom links<\/li>\n<li>key <code>url<\/code>: equals to <code>get_permalink()<\/code> or the manually entered url of a custom link<\/li>\n<li>key <code>title<\/code>: equals to <code>$post-&gt;post_title<\/code> or the manually entered title of a custom link<\/li>\n<li>key <code>type<\/code>: the <code>$post-&gt;post_type<\/code> or <code>null<\/code> for custom links<\/li>\n<\/ul><\/dd>\n<dt>How do I only show the links for a certain post_type in my theme?<\/dt>\n<dd><p>Set the <code>$post_type<\/code> in <code>get_related_links($post_type)<\/code> to <code>'post'<\/code>, <code>'page'<\/code> or any custom post-type. A simple example that show a list of links:<\/p>\n\n<pre><code>&lt;?php $related_links = get_related_links('page'); ?&gt;\n&lt;ul&gt;\n    &lt;?php foreach ($related_links as $link): ?&gt;\n        &lt;li&gt;&lt;a href=\"&lt;?php echo $link['url']; ?&gt;\"&gt;&lt;?php echo $link['type']; ?&gt;: &lt;?php echo $link['title']; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n    &lt;?php endforeach; ?&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><\/dd>\n<dt>How do I show the related links of another post (not the current one)?<\/dt>\n<dd><p>Set the <code>$post_id<\/code> in <code>get_related_links(null, $post_id)<\/code> to the id of the post. A simple example that show a list of links:<\/p>\n\n<pre><code>&lt;?php $related_links = get_related_links(null, 1); ?&gt;\n&lt;ul&gt;\n    &lt;?php foreach ($related_links as $link): ?&gt;\n        &lt;li&gt;&lt;a href=\"&lt;?php echo $link['url']; ?&gt;\"&gt;&lt;?php echo $link['type']; ?&gt;: &lt;?php echo $link['title']; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n    &lt;?php endforeach; ?&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><\/dd>\n<dt>How do I link directly to a media file?<\/dt>\n<dd><p>You need to check the <code>'type'<\/code> and then get with <code>wp_get_attachment_url()<\/code> the attachment url from the <code>'id'<\/code>.<\/p>\n\n<pre><code>&lt;?php $related_links = get_related_links(null, 1); ?&gt;\n&lt;ul&gt;\n&lt;?php foreach ($related_links as $link): ?&gt;\n    &lt;?php if ($link['type'] == 'attachment') :\n        $url = wp_get_attachment_url($link['id']);\n    else :\n        $url = $link['url'];\n    endif; ?&gt;\n    &lt;li&gt;&lt;a href=\"&lt;?php echo $url; ?&gt;\"&gt;&lt;?php echo $link['title']; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n&lt;?php endforeach; ?&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><\/dd>\n<dt>How do show the type of a media file?<\/dt>\n<dd><p>You need to check the <code>'type'<\/code> and then get with <code>wp_get_attachment_url()<\/code> the attachment url from the <code>'id'<\/code>.<\/p>\n\n<pre><code>&lt;?php $related_links = get_related_links(null, 1); ?&gt;\n&lt;ul&gt;\n&lt;?php foreach ($related_links as $link): ?&gt;\n    &lt;?php \n    if ($link['type'] == 'attachment') :\n        $url = wp_get_attachment_url($link['id']);\n        $mime = explode('\/', get_post_mime_type($link['id']));\n        $mime = $mime[sizeof($mime) - 1];           \n    else :\n        $url = $link['url'];\n        $mime = null;\n    endif; \n    ?&gt;\n    &lt;li&gt;&lt;a href=\"&lt;?php echo $url; ?&gt;\"&gt;&lt;?php echo $link['title']; ?&gt;&lt;?php echo isset($mime) ? ' (' . $mime . ')' : ''; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n&lt;?php endforeach; ?&gt;\n&lt;\/ul&gt;\n<\/code><\/pre><\/dd>\n<dt>How to prevent a PHP error when the plugin is not activated?<\/dt>\n<dd><p>Put the <code>get_related_links()<\/code> function or your whole code into an <code>if<\/code> clause. Like this your theme will still work even if the plugin is deactivated.<\/p>\n\n<pre><code>&lt;?php if(function_exists('get_related_links')) : ?&gt;\n    &lt;?php $related_links = get_related_links(); ?&gt;\n    &lt;ul&gt;\n        &lt;?php foreach ($related_links as $link): ?&gt;\n            &lt;li&gt;&lt;a href=\"&lt;?php echo $link['url']; ?&gt;\"&gt;&lt;?php echo $link['type']; ?&gt;: &lt;?php echo $link['title']; ?&gt;&lt;\/a&gt;&lt;\/li&gt;\n        &lt;?php endforeach; ?&gt;\n    &lt;\/ul&gt;\n&lt;?php endif; ?&gt;\n<\/code><\/pre><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.7.1<\/h4>\n\n<ul>\n<li>Removed an obsolete console log that may cause problems on Internet Explorer 7 and 8.<\/li>\n<\/ul>\n\n<h4>1.7<\/h4>\n\n<ul>\n<li>Added a Widget to show the related links in your widgetized theme areas.<\/li>\n<li>Fixed a JavaScript error when adding custom links.<\/li>\n<li>Settings aren't reset after plugin reactivation.<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<ul>\n<li>Metabox loads new list items while scrolling. Leads to a better load and search performance when a blog contains many hundred posts. <\/li>\n<li>Use placeholder attribute for input fields.<\/li>\n<li>Use plugins_url() to load stylesheets and javascript.<\/li>\n<li>Enqueue jQuery UI correctly.<\/li>\n<\/ul>\n\n<h4>1.5.7<\/h4>\n\n<ul>\n<li>Added related_links() function to echo an unordered list of links<\/li>\n<li>Added media post-type to link to media files (thanks jhned)<\/li>\n<\/ul>\n\n<h4>1.5.6<\/h4>\n\n<ul>\n<li>Fixed a problem where empty post data could lead to a php error<\/li>\n<\/ul>\n\n<h4>1.5.5<\/h4>\n\n<ul>\n<li>Fixed the marking of already selected links in the list (thanks robert_k for the fix)<\/li>\n<\/ul>\n\n<h4>1.5.4<\/h4>\n\n<ul>\n<li>Fixed a bug where get_related_links() always returned custom links when the post_type parameter was set<\/li>\n<\/ul>\n\n<h4>1.5.3<\/h4>\n\n<ul>\n<li>Updated CSS for WordPress 3.3 <\/li>\n<\/ul>\n\n<h4>1.5.2<\/h4>\n\n<ul>\n<li>Updated the way how settings are saved to be compatible with future WordPress versions<\/li>\n<\/ul>\n\n<h4>1.5.1<\/h4>\n\n<ul>\n<li>Fixed a bug where the plugin was also loaded on the taxonomy admin pages<\/li>\n<\/ul>\n\n<h4>1.5<\/h4>\n\n<ul>\n<li>Links order can be changed with drag and drop<\/li>\n<li>Search field to quickly find a link by name<\/li>\n<li>External URLs can be added<\/li>\n<li>Added an <code>id<\/code> property to the get_related_links() function<\/li>\n<li>New meta data structure but legacy support for older plugin versions is added<\/li>\n<li>Checking if the post really exists before it is added to the output<\/li>\n<li>Better list loading through ajax<\/li>\n<\/ul>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>The meta box content list is now scrollable<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<p>Initial release<\/p>","raw_excerpt":"Manually link to existing content or a custom url through a meta box on the writing page.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/12775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=12775"}],"author":[{"embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/chabis"}],"wp:attachment":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=12775"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=12775"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=12775"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=12775"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=12775"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=12775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}