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

Trying to write shortcode with get_post_meta but isn’t working

There are several minor problems with your code:

Firstly, you are using shorthand PHP tags, like <?= /*some stuff*/ ?> they won’t work – see WordPress Coding Standards – No Shorthand PHP Tags.

Secondly, you are not echo‘ing the variable $client_name.

Last but not least, you are saving your post meta with the name _client_name, with an additional underscore at the front, but made a typo while trying to get it, the underscore is missing.

Related Posts:

  1. How to call a post’s metadata in shortcode.php?
  2. Form action/link to render a plugin in WordPress front-end
  3. Update postmeta Parent when post_status child change
  4. Metabox not show in categories custom post type cmb2
  5. custom post type category count shortcode
  6. WordPress request fiter order by related post’s post_title
  7. Display Child Pages of Custom Post Type Parent Page
  8. Shortcode to display Staff post type based on Location post type and Specialty post type
  9. Update database from Quick Edit according to Checkbox state of Custom Post Type
  10. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  11. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  12. Dynamic Custom Fields
  13. wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
  14. Shortcode for CPT post content in a page
  15. Show Custom Post Type meta boxes only on Page Edit
  16. Next Post links not working in custom post type shortcode
  17. Custom filter function not working with Custom post type
  18. Foreach inside shortcode not working as planned
  19. Importing Data from a Non-WordPress database, into WP
  20. Getting thumbnails of a custom posts featured images in a page-templates metabox
  21. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  22. Remove Post Custom Meta Box
  23. Can’t publish custom post type – “You are not allowed to edit this post.”
  24. Custom fields for custom post type
  25. Show future events based on custom field AND order by date
  26. Meta Data for Custom Post Type not saving
  27. Using preg_replace to filter custom textarea
  28. Can a shortcode included in post content add styles to the ?
  29. How to retrieve category of a post in have_post loop?
  30. Check if post with same meta value exists
  31. Filter date from post meta when date is in string format
  32. Get only used meta_values
  33. If Post Meta Equals Current Title Conditional Advanced Custom Fields
  34. Is there a way to exclude posts based on meta_values?
  35. Checking if looped item has a parent inside a shortcode
  36. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  37. Archieve.php not loading for custom post type
  38. Submitting Custom Post Types with custom fields from Front-end form
  39. get_post_meta is not working inside shortcode
  40. the_post() is printing titles in page footer
  41. create custom meta box with default value
  42. Get $post->ID from a URL
  43. Displaying a div from an assigned meta_value when on a page
  44. Meta data (Tags and Categories) for Custom Posts not showing.
  45. Display different information of a custom post type
  46. Create Array from custom post type to display a slider
  47. Setting Post Title via Meta Data returns Auto-draft
  48. How to Echo Metadata Value in Currency Format
  49. Issue on Working with Metabox – Checkbox to enable Sale Items
  50. Filter posts by tax (dropdown) and meta value
  51. delete_post_meta() for whole CPT / multiple posts?
  52. How to get specific post meta by title or id
  53. Publish and save specific postmeta to a filtered post_type
  54. Add custom attributes to a post
  55. How to move a post to different post type with all meta data?
  56. Why do I have to press the “Update” button twice to save my meta box values?
  57. Shortcode leaves no space for other elements?
  58. How can I display a drop-down select of Post Names
  59. how to show records that don’t have custom meta value
  60. How can I add a shortcode to query Custom Post Type with ACF in WordPress?
  61. Custom shortcode works in Elementor editor but not on frontend
  62. WP API Response does not show my registered metadata
  63. Get Posts by Category, Tag , and CPT Taxonomy
  64. How to detect that the save_post hook is calling the callback associated to the current edit post page only
  65. post_type internal ID?
  66. Custom post type Shortcodes wordpress
  67. $post->post_meta not pulling any post in wordpress/php
  68. Values from meta-box not on $_POST
  69. how to create custom post type with dynamic category_name using shortcode
  70. WP_Query of custom post type sorted by meta_key has unexpected results
  71. Add shortcode inside of the_content()
  72. WordPress Custom Post Type and Shortcode for Portfolio Items
  73. Returning a custom content types with meta values
  74. Custom post type suddenly stoped working after WordPress 5 update
  75. Batch Extract Date from post title and put into ACF custom field
  76. Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’
  77. copy images from custom field to another custom field
  78. Creating shortcode id for custom post types
  79. Shortcode is displaying the content on top of the page [duplicate]
  80. Filter content in shortcode
  81. How to show custom field on specific custom post type posts only when filled
  82. How to handle this specific case of custom post type?
  83. Shortcode with WP_Query more than once on one page
  84. posts within custom post type all share the same content in the front-end
  85. Save CTP post meta different values each day without overwriting previous values
  86. get_post_meta returns NULL in front-end, but correct result in back-end
  87. Shortcode to return single custom post based on post taxonomy
  88. Cannot obtain custom meta information
  89. Problem with adding custom post type meta to header by plugin
  90. is_main_query() never called on WP 4.4
  91. Change post type depending on shortcode
  92. Custom Post Type for Shortcode Use – Prevent it display as a post (with slug)
  93. How can I output WPAlchemy repeating fields meta values in my page template?
  94. Meta box data is saved but NOT displayed in the meta box text field. Why?
  95. Save Metabox Custom Field Value
  96. Echo custom post meta from options array
  97. Value of post meta dropdown is not showing in WordPress
  98. Meta box data not saving
  99. Get all metadata for a given custom post type
  100. Looking to Customize YouTube Video Embeds
Categories custom-post-types Tags custom-post-types, post-meta, shortcode
Override email_exists function
“Seen by” Feature in posts [closed]

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