If you place the code below in single.php file anywhere you want the links to appear in your posts, or inside a function in functions.php and the function tied to a filter or an action like ‘the_content’, the you shold get a list of links to the posts that have the same tag or tags as the post you are currently reading.
global $post;
$this_post_tags_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
$query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => -1, 'tag__in' => $this_post_tag_ids ) );
if ($query->have_posts()){
while($query->have_posts()){
$query->the_post();
echo the_title('<h3><a href="'.get_the_permalink.'"/>', '</a></h3>');
}
}
wp_reset_query();
I didn’t tested it, but it should work.
Related Posts:
- Internal Links to Pages in PHP?
- How to display page title+link of page created by user
- How to create wordpress page that shows posts with specific tags?
- How to exclude shortcode from specific page IDs if it’s set to global
- How to get the excerpt of a page before more tag?
- Add a Menu Link (to a WordPress Page) in the Admin Menu/Sidebar
- Why doesnt ONE of my links in the footer work properly? [closed]
- Relative instead of absolute links in pages?
- Related Links Page with moderated, user suggested link submissions
- How to make tag post listing page working?
- I can’t edit my homepage – the page editor is just blank [closed]
- How to get tagged pages to show up with tagged posts?
- Query pages based on tags
- Get all children titles of a page as a link to them
- anchor tag in header not working on other pages except the home page
- trying to add a author value in wp page links?
- Hide links to pages that dont have any content
- How do you run code on a specific page without missing the init hook?
- Add pagination to search.php page
- Access link page and not folder content of that link
- Search Page: activate html code if the tag is on the page
- How to achieve anchor links on top of pages.
- Tags are automatically converted if they match post names. Stop It!
- one time visit to the page
- Display list of posts with x tag within a page?
- Add tags to long page that is broken up into subpages?
- How to get a list of pages (not posts) with specific tags?
- Add infinite scroll to content splitted post
- Check if wp-login is current page
- How to update page status from publish to draft and draft to publish
- Customizing the URLs of WordPress Login and Sign-up Pages?
- Check IF is a “single product page” and Check the “role” for a Redirect
- A check for if is parent page, if has children, if has grandchildren
- How to add a specific widget to only 1 page?
- Get wp_get_attachment_url outside of loop
- How to add or remove metabox each page separately?
- How to display list of child pages of parent page in wordpress?
- Automatically change page password
- Remove pages from backend list *and* update counter accordingly
- How do i fix? WordPress database error: You have an error in your SQL syntax;
- WordPress Admin – Add Edit link to specific page under Pages Menu
- Show child pages and sibling pages on the child page
- How do I use featured images on index.php?
- Making a wordpress page the index on the site?
- Using Pages to handle calls for custom post types
- Displaying Subpages while on Parent page?
- Guest authors, sort of like Wikipedia, but more theme-able
- Pages views limit [closed]
- Redirect to page list when page published
- Get the url of a page template without using the page slug and ID
- Having wordpress page accesss issue under sub-directory
- Add external css to Contact Page
- Role can edit just one page [closed]
- how to edit source code of specific page in wordpress?
- Cannot enter “::before” for li tag when editing a WordPress page
- cannot link a external url, present page url acting as parent url
- How to get page_id for url rewrite or how to use page slug for calling a page?
- JQuery Plugins in WordPress
- Dynamic href link to Contact Page
- how can i remove page title on desktop view
- Is there a way to schedule changes to a page?
- Option for pages order in backend
- Return subpages of an author if the parent page was published by an other author
- Page menu not showing in admin, new Page button missing in toolbar too
- Allow a user to edit their own page and profile only
- Short link to read complete post
- Delete all Tag Links from Posts
- Custom folder for wordpress page templates
- Tag template not returning posts [closed]
- Editing Help Section
- Separate URL for a specific page
- Pages that don’t look like blog posts?
- Next and Previous Page links based on ‘Order’ attribute
- Create multiple pages with tables from json file
- Attaching a file to a page without adding to media library?
- Every change made by “Author” role is going to “pending review”
- Groping Pages Per Department Option
- Requiring a Visitor to Enter a Password Each Time They visit a Page
- WordPress default theme cannot get full page on entry content div
- Create multiple custom HTML pages
- Can I link to content dynamically from a page to a new page?
- How to remove the duplicate title tags and duplicate meta descriptions?
- Two different layouts for the same post
- My page title turns into a h2 tag – What to do?
- problem with loading pages
- How to turn post into pages and via versa?
- Content not displaying on page
- Edit Page Content not showing
- Managing many pages on a WordPress website
- How to get sort content by page id?
- Avada Theme – Display results from a specific category [closed]
- Search page different title per results
- Approve Page Edits
- Passing form data via AJAX to REST API And displaying results
- Footer doesn’t display in page.php
- Load new Posts on Scroll on Page
- Default pages to be unpublished – possible?
- How do you add a featured image to a page (not post)?
- All pages duplicated like a mirror with critical errors
- How to change the default location where new post gets stored?