{"id":251,"date":"2020-06-09T07:04:51","date_gmt":"2020-06-09T07:04:51","guid":{"rendered":"https:\/\/codexjunction.com\/?p=251"},"modified":"2023-10-29T17:02:45","modified_gmt":"2023-10-29T17:02:45","slug":"get-post-page-url-in-wordpress","status":"publish","type":"post","link":"https:\/\/codexjunction.com\/get-post-page-url-in-wordpress\/","title":{"rendered":"Get Post Page URL in WordPress"},"content":{"rendered":"<p data-sourcepos=\"1:1-1:170\">To get the post page URL in <a href=\"https:\/\/codexjunction.com\/html-vs-wordpress\/\">WordPress by using code<\/a>, you can use the <code>get_permalink()<\/code> function. This function returns the full permalink for the current post or post ID.<\/p>\n<p data-sourcepos=\"3:1-3:125\">To use the <code>get_permalink()<\/code> function, simply pass in the post ID. You can get the post ID using the <code>get_the_ID()<\/code> function.<\/p>\n<p data-sourcepos=\"5:1-5:79\">For example, the following code will return the <a href=\"https:\/\/www.hostinger.in\/tutorials\/what-is-a-permalink\" rel=\"nofollow\">permalink<\/a> for the current post:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<div class=\"code-block-decoration header gmat-subhead-2 ng-star-inserted\">PHP<\/div>\n<pre><code class=\"code-container\" role=\"text\"><span class=\"hljs-variable\">$post_permalink<\/span> = get_permalink( get_the_ID() );\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"11:1-11:183\">You can also use the <code>get_permalink()<\/code> function to get the permalink for a specific post ID. For example, the following code will return the permalink for the post with the ID of 123:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<div class=\"code-block-decoration header gmat-subhead-2 ng-star-inserted\">PHP<\/div>\n<pre><code class=\"code-container\" role=\"text\"><span class=\"hljs-variable\">$post_permalink<\/span> = get_permalink( <span class=\"hljs-number\">123<\/span> );\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"17:1-17:151\">Once you have the post permalink, you can use it however you like. For example, you could display it in a post template, or you could use it in a link.<\/p>\n<p data-sourcepos=\"19:1-19:75\">Here is an example of how to display the post permalink in a post template:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<div class=\"code-block-decoration header gmat-subhead-2 ng-star-inserted\">PHP<\/div>\n<pre><code class=\"code-container\" role=\"text\">&lt;a href=<span class=\"hljs-string\">\"&lt;?php echo get_permalink( get_the_ID() ); ?&gt;\"<\/span>&gt;<span class=\"hljs-meta\">&lt;?php<\/span> the_title(); <span class=\"hljs-meta\">?&gt;<\/span>&lt;\/a&gt;\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"25:1-25:71\">This code will generate a link to the post with the current post title.<\/p>\n<p data-sourcepos=\"27:1-27:18\">I hope this helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get the post page URL in WordPress by using code, you can use the get_permalink() function. This function returns the full permalink for the current post or post ID. To use the get_permalink() function, simply pass in the post ID. You can get the post ID using the get_the_ID() function. For example, the following code will return the permalink for the current post: PHP $post_permalink = get_permalink( get_the_ID() ); You can also use the get_permalink() function to get the permalink for a specific post ID. For example, the following code will return the permalink for the post with the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[512,263,508,510,511,509],"class_list":["post-251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-a-online-course-web-tutorial","tag-get-post-page-url","tag-learn-java-online","tag-learn-laravel-online","tag-learn-php-online","tag-learn-python-online"],"_links":{"self":[{"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":4,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":2672,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/posts\/251\/revisions\/2672"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/media\/282"}],"wp:attachment":[{"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexjunction.com\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}