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. Is there a way to batch-find unlinked text URLs in the body text of all my posts and link them?
  87. How to Programmatically Replace Characters in WooCommerce Product Slugs?
  88. How to add user_registered time in human_time_diff() wordpress
  89. Disable Attachment Page Except for Category
  90. sort by date in users
  91. Is it possible to set the first image from a gallery as the product image, rather than the featured image?
  92. Customizer cuistom CSS Priority ordre Issue
  93. wp_script_add_data not working
  94. Setcookie not setting cookies anywhere except admin
  95. WPDB query suddenly not working
  96. WooCommerce, change “Add to Cart” to “Link to Product”, only for specific categories
  97. Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023
  98. How to disable calculation costs of Woocommerce Booking plugin [closed]
  99. Copy and Modified WooCommerce function is_coupon_valid [closed]
  100. CF7 Remove Comma from ‘select’ ‘radio’ and ‘checkbox’ outouts
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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