Support » Fixing WordPress » Shortcode to link to a tag archive page

  • Resolved Bibhuti Bhushan Barman

    (@bibhutibbb)


    I don’t know the way but i strongly need this.
    Actually my blog post have to keyword and i linked the keyword to tag archive page. But for this I have to add tag page link manually, I want a shortcode for post page to directly linkback to tag archive page in keyword. for example If i write [Something] or [tag]Something[/tag] or [Tag=Something] the something text will auto linked to the Something tag archive page like Something.

    I have searched lot on google and wp support pages but could’t find the solution, If you anybody have the script or plugin then please share the process.

    Thanks in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • vtxyzzy

    (@vtxyzzy)

    I think the following will do what you want:

    add_shortcode('taglink','mam_tag_link');
    function mam_tag_link($atts,$content) {
       // Usage: [taglink]target[/taglink]
       // Generates a link to http://url/tag/target
       $url = home_url('/');
       $link ="<a href='{$url}tag/$content'>$content</a>";
    
       return $link;
    }

    Yeh! I just wanting this code. Thank you very much.

    A problem.
    This catching just the text what i type (ie- if i type [taglink]something[/taglink] it work but if i type [taglink]Something[/taglink] it not working because then link shows http://url/tag/Something that mean Capital letters is the problem and if i give a space also there is the same problem).

    If you have resourced about this then you may know the problem’s solution if it possible please tell me.

    Thanks..

    vtxyzzy

    (@vtxyzzy)

    Sorry, I should have checked for that. Please try this:

    add_shortcode('taglink','mam_tag_link');
    function mam_tag_link($atts,$content) {
       // Usage: [taglink]linktext[/taglink]
       // Generates a link like <a href="http://url/tag/linktext">linktext</a>
       $url = home_url('/');
       $target = sanitize_title_with_dashes($content);
       $link ="<a href='{$url}tag/$target'>$content</a>";
    
       return $link;
    }

    Now Just Ideal.
    Thanks a lot.

    Everythonh ok but a question.
    Is there any way to add a shortcut in TiniMCE post editor?

    vtxyzzy

    (@vtxyzzy)

    Please explain more what you want. If you want to enter a shortcode, just type it into the text of the post.

    Ok. I want a shortcode on TiniMCE, means in the TiniMCE there will show a button for the link to tag function and if i select any text and then click the button, the select texts will auto get functioned like [taglink]select text[/taglink].

    vtxyzzy

    (@vtxyzzy)

    That will require writing a plugin, probably with some javascript code to make the changes. Here is a Codex article that may help: http://codex.wordpress.org/TinyMCE_Custom_Buttons

    ok..I will read this and If get solved the issue I will post the things here.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Shortcode to link to a tag archive page’ is closed to new replies.