If I have lots of pages... page_ids 1-100... how do I link between the two in the editor?? I guess I can use <a href="/index.php?page_id=x">Link</a>
but that's not user friendly... I want to do something like <a href="<?= get_permalink(x); ?>">Link</a>
but that doesn't work either... help please... is there a handy plugin...
views:
41answers:
4
A:
There are plugins that you can use to insert PHP in your posts or pages. Maybe using one of those will let you use your second suggestion.
John at CashCommons
2010-04-01 15:42:08
+1
A:
Use a shortcode.
Add the following to your themes’ functions.php:
if ( ! function_exists('toscho_id_to_link') )
{
/**
* Creates a link from the post id.
*
* Usage: [link id=42 title="The Meaning of Life?" class="pseudophilosphical"]Guess![/link]
*
* Inspired by Sergej Müller
* @see http://playground.ebiene.de/2388/wordpress-shortcode-links/
* @param array $atts id (numeric) and additional HTML attributes
* @param string $data
* @return string
*/
function toscho_id_to_link($atts, $data)
{
// incomplete
if ( ! isset ( $atts['id'] ) or ! is_numeric($atts['id']) )
{
return $data;
}
// test
$url = get_permalink($atts['id']);
// No entry with this ID.
if ( ! $url )
{
return $data;
}
unset ( $atts['id'] );
$attributes = '';
// more attributes?
if ( ! empty ($atts) )
{
foreach ($atts as $key => $value )
{
$attributes .= " $key='$value'";
}
}
return "<a href='$url'$attributes>$data</a>";
}
add_shortcode('link', 'toscho_id_to_link');
}
You may find this plugin helpful: Simply show IDs.
toscho
2010-04-01 15:59:17
+1
A:
We use RB-Internal-Links. It allows you to link using a shortcode and slug, or even has a WYSIWYG interface.
Simon Scarfe
2010-04-02 08:19:16
I was about to suggest that plugin, as I use it myself, but looks like I found this question a few days too late.
Voyagerfan5761
2010-04-07 20:25:08
A:
You should really use complete and full URLs for all links in WordPress. http://example.com/index.php?page_id=123 , for example.
Using partial links will result in strange behaviors in feeds, on category archives, etc.
Otto
2010-04-02 20:51:18