GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   wordpress question: calling in the_permalink in post content? (https://gfy.com/showthread.php?t=928415)

Angry Jew Cat - Banned for Life 09-17-2009 07:52 PM

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 09-17-2009 08:06 PM

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

Angry Jew Cat - Banned for Life 09-17-2009 08:11 PM

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?

fris 09-17-2009 08:18 PM

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]

Angry Jew Cat - Banned for Life 09-17-2009 08:24 PM

Quote:

Originally Posted by fris (Post 16332775)
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...

fris 09-17-2009 08:37 PM

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

Angry Jew Cat - Banned for Life 09-17-2009 08:42 PM

Quote:

Originally Posted by fris (Post 16332841)
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');

Angry Jew Cat - Banned for Life 09-17-2009 10:04 PM

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?


All times are GMT -7. The time now is 05:07 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123