wordpress question: calling in the_permalink in post content?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Angry Jew Cat - Banned for Life
    (felis madjewicus)
    • Jul 2006
    • 20368

    #1

    wordpress question: calling in the_permalink in post content?

    Say I want a link within my content to link to

    Code:
    <?php the_permalink() ?>
    before i know what my actual permalink is, say for template use. What is the proper way to link to the_permalink in my template? i tried a simple

    Code:
    <a href="<?php the_permalink() ?>">
    sort of thing, but it doesn't really work. Any tips?
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #2
    dont know why you want too, but you could create a shortcode to do it, or via a plugin.

    http://justintadlock.com/archives/20...rdpress-plugin
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

    Comment

    • Angry Jew Cat - Banned for Life
      (felis madjewicus)
      • Jul 2006
      • 20368

      #3
      I am working on a script which automates my content creation for certain projects. All the post data is written into an XML file for importing into wordpress after it's creation. In my post template I would like to link an image from the excerpt into the single.php version of the_content. If you follow?

      Comment

      • fris
        Too lazy to set a custom title
        • Aug 2002
        • 55679

        #4
        heres a few others to look at

        http://justintadlock.com/archives/20...rdpress-plugin

        http://wordpress.org/extend/plugins/rb-internal-links/

        or some code to do it via your functions.php file

        Code:
        function print_link($atts, $content = null) {
                global $post;
                $permalink = get_permalink($post->ID);
                return '<a href="'.$permalink.'">'.$content.'</a>';
        }
        
        add_shortcode('mypermalink','print_link');
        then you would do
        Code:
        [mypermalink]title you want[/mypermalink]
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

        Comment

        • Angry Jew Cat - Banned for Life
          (felis madjewicus)
          • Jul 2006
          • 20368

          #5
          Originally posted by fris
          dont know why you want too, but you could create a shortcode to do it, or via a plugin.

          http://justintadlock.com/archives/20...rdpress-plugin
          I just tried this one, and it works very well aside from the fact that the shortcodes do not function within "the_excerpt" and only work in "the_content". I'll look through the other couple options you've listed. Thanks Fris...

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            you could probably modify it to work with excerpt as well, probably just 1 line of code to add the filter for excerpt as well as the_content
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            • Angry Jew Cat - Banned for Life
              (felis madjewicus)
              • Jul 2006
              • 20368

              #7
              Originally posted by fris
              you could probably modify it to work with excerpt as well, probably just 1 line of code to add the filter for excerpt as well as the_content
              Yup, added the following to my functions.php and the shortcodes now execute fine in the_excerpt with the Template Tag Shortcuts plugin...

              Code:
              add_filter('the_excerpt', 'do_shortcode');

              Comment

              • Angry Jew Cat - Banned for Life
                (felis madjewicus)
                • Jul 2006
                • 20368

                #8
                from one headache to the next. now i'm having trouble gettign the_excerpt to import from my XML file. The post imports fine, but the excerpt is left hanging Don't suppose you got much experience with creating XMLs for import do ya fris?

                Comment

                Working...