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

get_post_meta shortcode returns empty field

The shortcode callback function should always echo its output, not return it. Your code should be something like this:

function wcal_abandoned_cart_id_shortcode_callback( $atts ) {
    $atts = shortcode_atts( array(
        'post_id' => get_the_ID(),
    ), $atts, 'wcal_abandoned_cart_id' );

    echo get_post_meta( $atts['post_id'], 'wcal_abandoned_cart_id', true );
}
add_shortcode( 'wcal_abandoned_cart_id', 'wcal_abandoned_cart_id_shortcode_callback' );

If the output of your callback was HTML, besides echoing, you could just write your HTML outside of the PHP tag.

Related Posts:

  1. Adding Custom Fields for Img in Posts
  2. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  3. Redirect to another page using contact form 7? [closed]
  4. Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
  5. Update all posts automatically when using post_meta
  6. PHP Deprecated: Non-static method should not be called statically
  7. Update Multiple Post Meta for the Same Post In One call?
  8. How To Ignore a Filter On Applying Filter the Content In a Function
  9. Calling function from within functions.php returns unwanted value
  10. how to display all posts Custom fields dynamically?
  11. shortcode doesn’t work
  12. How to get custom field image url of specific size
  13. Can’t get custom posts of taxonomy to show
  14. Add multiple attributes to product from php
  15. Make the checkbox meta field checked by default
  16. Shortcode to generate and save password in a file
  17. get shortcode value
  18. Storing Options in a Shortcode
  19. Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
  20. How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
  21. How to put JQuery/Ajax inside shortcode?
  22. WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
  23. WordPress function not being called from jQuery method
  24. Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
  25. Nested shortcode functions accessing variable
  26. Some code in shortcode function being ignored
  27. How to Create a shortcode to this php function
  28. What is @Action in WordPress?
  29. Custom shortcode for displaying user based on a role parameter
  30. Return multiple values ​in a shortcode attribute
  31. Is there a way to convert shortcodes to html content?
  32. Shortcode not working – quotes seems strange
  33. Get all the URLs of the pages that uses a specific shortcode
  34. Add the_post_thumbnail_url to a shortcode in function.php
  35. Echo out element to another page.
  36. Adding a Tag Parameter / Filter to My Shortcode
  37. grab or load text on demand
  38. How to create repeater field manually, without plugin (ACF Pro)?
  39. What snippet do I need to type to show my ACF field show up on my theme?
  40. Is there a way to make [Table Of Content] plugin while not using revision data?
  41. need to find duplicated meta value in custom filed and view the posts that have the same value
  42. How to get current cart values using WC_Shortcodes?
  43. How do I use a plugin’s shortcode attribute value in another function?
  44. WordPress hide post from custom post-type on a single page
  45. Why does my custom plugin only function correctly once per page?
  46. Hide content for specific users with id
  47. Why is my shortcode not working?
  48. Get Shortcode output to database for static post_content
  49. Custom Field used to allow a Free Story; no longer works
  50. Get and Update Most Meta Value as an array in HTML form
  51. How to pass multiple custom fields as shortcode’s parameters
  52. How to get post that has non zero or greater than zero meta value
  53. Problem with conditional woocommerce custom checkout field
  54. Same Title on two different post type with single custom taxonomy
  55. Query Shortcode from a multisite to appear on a different site?
  56. Find all strings between an enclosing shortcode
  57. Creating a user ‘add custom field’ section
  58. Posting code inside the post instead of in the template file using shortcode
  59. How to Set Limit with WordPress Get Bookmarks Shortcode
  60. WordPress User Frontend Editing Custom Fields
  61. ACF: Hide a div or template section when a custom field (in a field group) is empty
  62. Creating Features List in WordPress Post
  63. Integrate Razorpay quick payments plugin with contact form7 plugin
  64. cURL External API request displays content above other content on page
  65. Subtract Using GravityWP Count Plugin
  66. How to get URL param for pagination in shortcode?
  67. qTranslate‑X is not translating all shortcodes
  68. Fields are not displayed on front end under custom php code in Advanced Custom Fields and Flexible Content field WordPress
  69. How can I see all the actions attached to an “add_action” hook?
  70. How can I import a class privately into a plugin?
  71. Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
  72. How to display multiple Post meta_key/meta_values by SQL query
  73. Updating WooCommerce variable product stock issue
  74. How can I show drafts in wp_dropdown_pages list?
  75. How to Create a Directory in a Plugin Folder?
  76. White text on white background in TinyMCE when wp_editor is called in WP 3.9
  77. HELP: Integrating WP with raw PHP code once published button is hit
  78. How do I add advanced custom fields / meta fields to Elasticsearch? [closed]
  79. Loading class files via autoload method
  80. Modifying Footnote Plugin for Descriptive Title Attributes
  81. I would like to use create a function in my custom plugin to tell WP to use a different header
  82. bulk change of image setting “link to” to “link to: image url “
  83. Escape when echoed
  84. add_meta_box (Will display only in specific page admin WordPress)
  85. Make id column as AUTO INCREMENT on plugin activation
  86. Sending email from inside a plugin using PHP PEAR
  87. How can I create a list of page titles from custom meta values?
  88. Notepad sticky plugin
  89. WooCommerce Custom Product to checkout
  90. How to stop or remove an action being called inside a function of an extended class
  91. How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
  92. Date calculations from 2 custom fields
  93. Easiest way to add dropdown to a page
  94. How to enable specific plugin only based around shop manager role?
  95. Adding a new field to the address field type in gravity forms
  96. Show admin notice on incorrect value on form field
  97. WooCommerce specifc variations for specific user role [closed]
  98. Calling an attribute from a plugin shortcode
  99. accessing wp.media api from a tinymce plugin
  100. Visual Composer shortcode for child theme dir
Categories plugins Tags custom-field, php, plugins, post-meta, shortcode
Rewrite Search URL Permalink For CPT Custom Taxonomies
How to rename a wordpress site from http://myserver.example.com/blog to http://myserver.example.com/somethingelse or just http://myserver.example.com

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