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. Custom Dynamic Tag in Elementor not showing image
  70. How to override plugin function in code snippets WordPress
  71. How to make a Template page to show the information of different things Shop and Product page?
  72. How to fix Fatal error: Cannot redeclare get_cli_args() in class-wp-importer.php
  73. Split Million WordPress Post’s Into Multiple Database Server
  74. How to create a “Most Popular” & “Latest” TAB in WordPress
  75. Is there any WordPress Plugin that provides video editing from front end side? [closed]
  76. How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]
  77. Creating a Table Row by Row
  78. Getting 504 Gateway Timeout Error on AWS Server! [closed]
  79. Order custom post type by posts with most likes first
  80. Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
  81. How to fix template and image buffering issues on website [closed]
  82. WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there
  83. How to trigger plugin migration code when plugin updates?
  84. How to Save Category and Delete Category in same Function
  85. PHP FATAL ERROR
  86. WordPress Throwing Deprecated Errors on its own Files
  87. public custom posts not showing in my wordpress plugin
  88. Problem with a shortcode generating a error [closed]
  89. Use inline callable for hooks and filters
  90. How Create LastMod and Update Date Only on Taxonomy Category and Tags
  91. Error in using ‘admin_enqueue_scripts’ action through a class
  92. Shortcode Displays 2 times
  93. How to execute a shortcode within a custom field?
  94. plugin doesn’t retrieve data from database
  95. I want to allow certain file types on dokan upload files
  96. How to create different woocommerce single_product.php pages for each product? [closed]
  97. Accessing Correct Database to Create REST API Endpoint
  98. How do I replace a logo image that’s hard-coded into a plugin’s logo.php file?
  99. additional fields based on the quantity of products selected
  100. Display file contents within Plugin
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
  • 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