Abdullah Jibaly
Abdullah Jibaly

Reputation: 54790

Inserting a link to another post in Wordpress

I'm putting together a site based on a Wordpress template, and was wondering if there's a way to link one post to another without entering the full URL. I'd like to be able to use something that doesn't change if the parent directory or subdomain changes. Any ideas?

Upvotes: 0

Views: 2426

Answers (3)

megi
megi

Reputation: 11

use below code to get particular post url and Title only by post id.

replace $postid with your post id that you want to display.

$postid = 1;  
echo '<a href="'.get_permalink($postid).'">'.get_the_title($postid).'</a>';

Upvotes: 0

Andrew Flanagan
Andrew Flanagan

Reputation: 4277

Posts

To link to a Post, find the ID of the target post on the Posts administration panel, and insert it in place of the '123' in this link:

<a href="index.php?p=123">Post Title</a>

Categories

To link to a Category, find the ID of the target Category on the Categories administration panel, and insert it in place of the '7' in this link:

<a href="index.php?cat=7">Category Title</a>

Pages

To link to a Page, find the ID of the target Page on the Pages administration panel, and insert it in place of the '42' in this link:

<a href="index.php?page_id=42">Page title</a>

(From Wordpress)

Upvotes: 3

Chris Doggett
Chris Doggett

Reputation: 20757

Linking Posts, Pages, and Categories

Something like: <a href="index.php?p=123">Post Title</a> should work even if you use permalinks.

Upvotes: 1

Related Questions