Don’t forget to use esc_url()
echo '<a href="'. esc_url( $link ).'">Welcome</a>';
Also try this: get_permalink( get_the_ID() );
Related Posts:
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- Removing rel=”nofollow” from links posted in Post Content
- How should I add links to other pages/posts from my post?
- How to do set post permalinks using 6 digit random unique function?
- How to handle broken links created by permalink/slug changes?
- Link to date_query results in WordPress
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Internal linking to posts permalink fail because of spaces and stripe at postname
- How to link post titles on page A to its posts on page B?
- My posts section for logged in user
- Make assigning post to a specific category equivalent to assigning it to all categories
- Modifying the permalink href for posts with jquery
- Read more link not working [closed]
- After the local installation of an old WP website I can see the homepage but I can’t access to the articles, why?
- How to use “Add link” pop up for a WordPress widget
- Use category base slug in posts’ permalink
- Random sort within an already sorted query
- Search by Hyphen
- Custom permalink structure only for default posts
- Exclude drafts in all() view of edit.php
- Change the Slug of Post Type post to baseurl/post/%postname%
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How to query posts with current or future date only
- Pagination not working on Custom Page Template
- Must permalinks always point to single post pages?
- Create new WordPress post [wp_insert_post] based on results of a WP_Query
- How to add padding between posts
- Add few specific post ids to wp_query
- Custom Order in WP Query
- Permalink Settings: optional settings doesn’t apply to editor
- How to change the page break URL from ../post/2 to …/post/page2/
- Search query – exact post title match
- How to get most recent commented post above new submitted post in WordPress?
- How to start with post number x?
- Setting up navigation links for posts (first, prev, next, last)
- Automatic post deletion
- I want to get title name of post, but i didn’t get by this code. Any suggestion?
- Delete post by giving its link
- How can I show many posts an author has per week?
- Change post order random through out the entire WordPress
- How to exclude latest x posts from a paginated query?
- Ajaxify This Code
- Pausing and Resuming WP_Query results
- How to : pagination in 3 different custom loops on the same page
- How could I change my Permalink from blog to custom structure? [closed]
- Permalink doesn’t get displayed in Twitter button (Local WordPress problem?)
- Query Posts by Custom Field
- how can i change WP main archives loop to sort by name or title
- Loop doesn’t exclude the specified category in home page
- Can’t get full post title if there a spaces in title
- why the same code got different results when using query_posts in functions.php and index.php
- Migrate posts from category and sub-category via SQL
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- WP_Query: Show 10 posts in date order, first three random
- register_post_type permalink
- WordPress Loop: How to display recent posts in multiple divs
- Random posts that always include a particular post?
- Conflict array_splice on loop and query in widget
- Exists filter or action that change Add New Post link?
- WP_Query of Category Not Showing First Post
- Link from Post to Another Post Via Clicking on Words within Original Post
- Change content off every sixth element
- Link to older links
- how to create a sub section in posts
- Categories Listing and Highlighting current category item
- WP_Query get posts in custom database table [duplicate]
- WordPress Query – Display 5 posts (same post type), each from a given tag
- Edit post & page option does not display on latest wordpress
- While loop in functions.php outputting the_title() of each post on frontpage
- Show posts from two specific category in WP_Query
- Permalink Short code showing unnecessary link text inside the loop
- How to create loop of posts except post ID defined via ACF field
- a WordPress connected to 2 database
- WP_Query that targets all categories
- Fill the exclude array() in get_posts()
- Prevent Archive URLs
- Double loop output
- Displaying a specific sub-category’s posts from wp_query
- How to give priority to page than to posts permalink structure?
- Custom layout manager for posts
- Get results from the main wp_query
- Post List Widget with custom posts and editing the Read More Link
- Advanced Post Display/Pagination/Ordering
- Is there a way to change the complete URL of the blog post for a redirecting tracking link?
- WordPress with static posts page and custom permalink structure doesn’t find posts with numeric permalinks
- Can’t seem to replicate permalink structure for localhost development site
- Pagination for custom query won’t let me back on page 1
- How to mix pages and sub-categories in a url
- WP_Query retrieve custom posts but not the post showing
- Changing permalink of custom category
- Overwrite URL on blog posts
- How to get single post by one author?
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- How do I add /blog/ on my permalink without affecting the portfolio project types permalink?
- Permalink remain the same on each page
- List posts related to category on a div [closed]
- Wp_query WooCommerce products
- posts_per_page – Repeats only first posts ‘post__in’ array
- query_posts different amount of posts per page [duplicate]
- Filters do not work when there are multiple (one works)