Hikari Internal Links – Exemples
This article provides information and exemples of all available parameters for Hikari Internal Links's shortcode.
As you're probably already aware, this plugin is used to build dynamic links to a Wordpress' website internal links. These links can point to posts, pages, custom post types, comments, categories, tags, custom taxonomies, and feeds to categories, tags and a post's comments.
That's done using the [hkLink]
shortcode. It's alternatively also available the [p2p]
shortcode for compatibility with other Post to Post based plugins.
- Introduction
- Shortcode Content
- <span>::CODECOLORER_BLOCK_9::</span> and <span>::CODECOLORER_BLOCK_10::</span> parameters
- <span>::CODECOLORER_BLOCK_25::</span> parameter
- <span>::CODECOLORER_BLOCK_29::</span> parameter
- <span>::CODECOLORER_BLOCK_34::</span> parameter
- <span>::CODECOLORER_BLOCK_39::</span> parameter
- Conclusion
- Related Posts
- Comments (6)
Shortcode Content
Let's start with the shortcode content, the text that comes between [hkLink] [/hkLink]
. Any text that goes there will be used in the link text, which goes between <a> </a>
and is visible in browsers.
An exemple is [hkLink]this post[/hkLink]
, which buils this post.
If you wanna use the resource title as the link text, we should just leave the shortcode content empty, or not use [/hkLink]
at all. Unfortunately Wordpress' shortcode parser is bugged and that doesn't work, we must use a text in the shortcode content for the shortcode be properly recognized. Therefore, I created the flag {{title}}
to be used in shortcode content, meaning the link text must be the resource title.
An exemple is [hkLink]{{title}}[/hkLink]
, which buils Hikari Internal Links – Exemples.
type
and value
parameters
The most important parameter of our shortcode is type
, it informs the resource type that should be linked. It works together with the value
parameter, which is the value related to that resource type.
An exemple is [hkLink type="id" value="754"]link text[/hkLink]
, which builds link text, in this case a link to one of my pages, which has ID of 754.
Here are all possible values for type
parameter:
- id: link to a post/page/custom type, and value refers to its ID,
type="id" value="0"
are default values when no type and value parameters are provided, and whenvalue="0"
it uses current resource - slug: link to a post/page/custom type, and value refers to its slug, exemple:
[hkLink type="slug" value="archives"]my <em>archives</em> page[/hkLink]
, my archives page - comment: link to the post where that comment in available, using anchor to that comment, and value must refere to a valid comment ID. If you are using my Hikari Titled Comments plugin and that comment has a title, its title is used in the link. Exemple:
[hkLink type="comment" value="1850"]{{title}}[/hkLink]
, comment 'Nice' @ 'Hikari Unicornified Gravatars'. - cat_slug, tag_slug, tax_slug: link to a category/tag/custom taxonomy, and value refers to a slug. Exemple:
[hkLink type="cat_slug" value="en"]{{title}}[/hkLink]
, Tutorial English. - cat_id, tag_id, tax_id: same as before, but value refers to a category/tag/custom taxonomy ID. Exemple:
[hkLink type="cat_id" value="47"]{{title}}[/hkLink]
, Tutorial English. - post_feed: link to a post feed, which lists that post's comments, here value can be either the post ID or slug. Exemple:
[hkLink type="post_feed" value="716"]{{title}}[/hkLink]
, Comments feed for 'Hikari Email & URL Obfuscator'. - cat_feed, tag_feed: link to a category/tag feed, which lists its posts. Its value parameter can also be its ID or slug. Exemple:
[hkLink type="cat_feed" value="47"]{{title}}[/hkLink]
, RSS feed for category 'Tutorial English'. There's also tax_feed, but it's not implemented yet because it seems Wordpress doesn't provide RSS feed for custom taxonomies.
section
parameter
If you wanna point to a specific section of a page, and it has an anchor refered by an id attribute (exemple: <div id="section"></div>
), you can use the section parameter so that the link points there.
Exemple: [hkLink type="slug" value="wordpress" section="comments"]Leave a comment on my plugins list page[/hkLink]
, Leave a comment on my plugins list page.
attributes
parameter
Say you wanna use a specific class on your link, or even the infamous target="_blank"
. That can be done with the attributes
parameter.
Anything added in this parameter will be included in the built link, regardless of what it is.
Exemple: [hkLink attributes="id='special-link'"]this link is special and has its own id attribute[/hkLink]
, this link is special and has its own id attribute (see page source to verify this link has that attribute in it).
Be careful to not create XHTML invalid links using this parameter.
title_only
parameter
What happens if you wanna use only a post title, without having a link to it, and be safe in case you change the post title later?
title_only
parameter is here to save you! It forces the result of its shortcode use only the resource's title, stripping the rest of the link.
Exemple: [hkLink type="comment" value="1744" title_only="1"]this text isn't used at all[/hkLink]
, comment 'PHP4 not supported!' @ 'Hikari Email & URL Obfuscator'. If that attribute wasn't used, we'd have [hkLink type="comment" value="1744"]{{title}}[/hkLink]
, comment 'PHP4 not supported!' @ 'Hikari Email & URL Obfuscator'.
taxonomy_type
parameter
This one is used together with tax_slug, tax_id and tax_feed types.
You probably was astonished on the need of different types for category, tag and custom taxonomy. Unfortunately, even though they are all taxonomies and are stored together in database sharing unique IDs, Wordpress API always requires the taxonomy type to be provided.
Category and tag have specific functions that refere to real functions passing their tax type, but custom taxonomies require their type to be provided.
Because of that, when you use tax_slug, tax_id and hereafter tax_feed types, you must also use taxonomy_type
parameter to inform its taxonomy type to Wordpress.
For category and tag links, this parameter isn't needed, and if it's provided it's ignored.
Conclusion
I hope this article is able to properly document how to use Hikari Internal Links shortcode. If any question about its use remained, just leave a comment in this post and I'll try to help.
Always remember that type-value pairs that are unable to be converted to a resource will generate an error message under the wpdberror class. This is a Wordpress standard class, and when Hikari Internal Links is active the content of any HTML element with that class is viewable to you, but not to your visitors. Make some tests with invalid IDs and slugs, while being logged in and logged of, to see how it looks like.
Here's a final exemple with all parameters in use: [hkLink type="id" value="677" section="comments" attributes='']{{title}}[/hkLink]
, Travian ModKit 2.0.
Have fun and tnx for using my plugins .
Popularity: 20%
It has accumulated a total of 72,263 views. You can follow any comments to this article through the Comments RSS 2.0 Feed. You can leave a comment, or trackback from your own site.
Readers who viewed this page, also viewed:
Related Posts:
- Hikari Internal Links
- Hikari Email & URL Obfuscator - JavaScript markup
- Wordpress
- Hikari Featured Comments
- Hikari Email & URL Obfuscator - Advanced Usage
- Hikari Email & URL Obfuscator
- Wordpress Large post showing blank / empty?! NO WAY!!
- Hikari Krumo
- Wordpress comments: new built-in feature X Wordpress…
- Finding theme folders for parent and child
-
Comentando vc contribui e participa na criação do conteúdo do site.
Contribua. Commente. :)(Os comentários abaixo representam a opinião dos visitantes, o autor do site não se responsabiliza por quaisquer consequências e/ou danos que eles venham a provocar.)
How do I...?
participate
How do I link "post A" to "post B" using "post B's" title?
information
If, from inside postA, you wanna link postB using postB’s title, you can just use
[hkLink type="id" value="754"]{{title}}[/hkLink]
, that will result in WordPress.But if you wanna link postB and use postA’s title as the link text, then unfortunately that can’t be done as the plugin works now. Each shortcode referes to a unique post and all its properties are related to that post, you can’t have a unique shortcode using postB’s URL as link href and postA’s title as link text.
To do that 100% dinamically, you’d need a shortcode to print postB’s title as plain text and another shortcode to take that text and add it to a link. But WordPress’ shortcode parser doesn’t support nesting shortcodes of the same tag, it just breaks.
It would be
[hkLink type="id" value="754"][hkLink type="id" value="716" title_only="1"]{{title}}[/hkLink][/hkLink]
, but it doesn’t work: [hkLink type="id" value="716" title_only="1"]{{title}}[/hkLink].You can still use any static text for link text:
[hkLink type="id" value="754"]My other post title[/hkLink]
, My other post title.feedback
Thank you.
marketing
Thank you for explaining that. I am new to this internal linking stuff and was getting frustrated. You have solved that and I appreciate it.
Thanks all
research
i like this plug in
Hi
could you help me please?
I am trying to make links for a map with clickable regions in http://www.virginads.co.uk/ (http://www NULL.virginads NULL.co NULL.uk/) based on custom fields.
Field values: South East,London,South West,East of England,Yorkshire and the Humberside,Wales,West Midlands,East Midlands,North West,North East,North Ireland,Other.
Field name: Region
Meta name: cp_state
this is the code for 1 of the image links I have tried to us, but it doesn't work:
What am I doing wrong?
Thank You in advance,
Helmuts
information
Hello, very interesting your use! :D
What the shortcode does is convert its string into a link, or an error if it fails to do so.
What’s the output it’s generating? There are many situations you must verify.
What final output do you get from that map? Since it’s also being generated dynamically, maybe its generator runs after ‘the_content’ filter runs, or after do_shortcode() filter executes, and then no shortcode is viewed and converted properly.
In your site I see you have the map in a widget, is your site running shortcodes in widgets? WordPress doesn’t have this filter by default, you must add it.
You can add it to a plugin or even to your theme’s functions.php. You can also try to put that map in a post and see if it works in this case.