Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to add a meta information to the URL?

Just got a solution: Just add this code to your functions.php and replace ‘_metainfo’ by your meta information and ‘posttype’ by your posttype.

function add_meta2url( $link, $post ) {
  $post_meta = get_post_meta( $post->ID, '_metainfo', true );
      if ( 'posttype' == get_post_type( $post ) ) {
        $link = $link . '#' .$post_meta;
        return $link;
     }
}
add_filter( 'post_type_link', 'add_meta2url', 1, 2 );

Unfortunately, the ‘#’ cannot be replaced by any other special character like ‘-‘, otherwise the url is responding with a 404 error message.

Related Posts:

  1. meta tags doesnt fetch data from permalinks
  2. Create Custom URL structure for specific Post category using Post ID instead of post name
  3. Custom route and extract data from slashes and parameter
  4. reWrite wp-content url to point on my cdn
  5. Add #primary at the end of navlink permalinks on single posts
  6. What’s the difference between home_url() and site_url()
  7. Prevent “main” WPMU site_url() being returned in functions
  8. Custom page with variables in url. Nice url with add_rewrite_rule
  9. Relative URLs and hide /wp-content/themes/
  10. Is it possible to use a forgot password url filter?
  11. Create Custom URL structure for specific Post category
  12. Add options to featured image
  13. How do you permanently remove default rewrite rules from the wp_options table?
  14. Change meta tags programatically
  15. Use a function to update post meta based on other post meta
  16. update_post_meta for custom field not working upon form submission
  17. How can I rename the WordPress AJAX URL? [duplicate]
  18. Assign category using custom field?
  19. Convert User ID’s to User Names in a single.php file
  20. How can I create a page with a specific URL?
  21. Ninja form Redirect depending on text field content [closed]
  22. Can’t check if a post has thumbnail adding filter to get_post_metadata()
  23. Move Post to different category if post_meta field is 0 or is 2 days old?
  24. How to rewrite the custom url in wordpress?
  25. wp-comment author- url +, email filter hook
  26. What WordPress function to use to get meta value by using meta keys?
  27. Removing custom meta data
  28. WordPress on AWS Auto scaling and ELB giving 503
  29. WordPress converts media extention URL automatically to video player
  30. Default Custom Field Value Automatically Update
  31. Post meta not updating
  32. Function to update post_meta based on existing post_meta
  33. Exclude from the query posts with meta_key and meta_value
  34. Get arguments from URL
  35. Prevent custom field from being updated after first publish
  36. Get array of metakey in all posts
  37. User function to return multiple get_post_meta()
  38. Add unique id to Preview URL
  39. Page get parameter doesn’t work with is_single() function
  40. What are the meta fields for an attachment?
  41. How to rewrite wordpress search to work on specific category
  42. How can I set the SRC URL of the custom logo image?
  43. Need to convert image url to a Base_64 data url with wordpress function..
  44. How to Add Shortcode to html img code?
  45. Protect get_query_var from manual input in url
  46. Problem with images URL after filter applying
  47. Rewrite Question Mark in Post Template with URL Parameter for clean URLs
  48. How i can get the URL?
  49. include w_thumbnail_src in function?
  50. How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
  51. How to avoid saving empty data to sql while using add_meta_box
  52. How to change text color depending on the number value (Using javascript)
  53. Fetch URL parameter
  54. how can I change all wordpress media file url to custom cdn url?
  55. How to add custom metakey to shop_order page’s searching function?
  56. How to Override Page Template if URL matches query?
  57. Update wp_postmeta table based on 2 keys
  58. blank page with wp_get_attachment
  59. Set URL Parameter Post Layout As Default
  60. Reference multiple style sheets, clearing styles for permalink page, custom fields for css
  61. How to change form action of wp-login page with a function
  62. How To Display Author Popup on Entry Meta (Genesis Framework)?
  63. Creating a “Related Meta” type field?
  64. Route wordpress with template
  65. Remove post from latest posts after a month only with certain tag
  66. save_post doesn’t correctly process function call with php class
  67. Rewrite rules and the permalink
  68. Edit meta fields from within template
  69. Using Switch Statement to Change Image According to Last Digit of Topic ID
  70. Return ACF Field value function
  71. Instead of using $post, how do i get the thumbnail image of the $post
  72. Problem with add_rewrite_tag
  73. update_post_meta not working in function
  74. How To Get WordPress Categories Last Update Date?
  75. Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
  76. How do I change the URL returned by next_posts_link()?
  77. Function in functions.php by url
  78. update_post_meta after form is submited
  79. Add custom fields after post/page title
  80. Remove base from the custom post type URL [duplicate]
  81. Display post_meta-by_key on product catalogue
  82. How to save custom made object in an array in a post meta field
  83. Adding and updating repeating custom field meta data
  84. Please give me the rewrite rules for my ugly urls
  85. WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
  86. function to include is_home, is_archive, is_category, is_author etc in one function?
  87. get_the_excerpt() not returning anything when post has no excerpt
  88. Query children and parent title
  89. Creating loop within functions.php
  90. Limit filter upgrader_post_install to a single plugin
  91. creating shortcode to pull json array
  92. hide shortcode using hooks
  93. Adding code using functions.php in child theme
  94. How can I change the size of the text in Word Press
  95. Get users with different roles and call function on each of them (user_meta)
  96. Show errormessages on wrong username/password on custom loginform?
  97. Class parameter in get_avatar args doesn’t get added to output
  98. locking content with overlay/pop up ads
  99. How to retrive previous Domain URL in Wp
  100. Update post meta with wp cron
Categories functions Tags functions, post-meta, url-rewriting, urls
setcookie not working when defined with ‘/’ but working if not defined
Fully mask *all* traces of WordPress installation subdirectory?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress