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 not working on my custom-function page

WordPress uses a global $post to keep track of the current post the user is viewing. Whenever you call functions like the_title() or get_the_ID() it uses that global $post to pull that data. In your code snippet you’re using get_posts() which generally does not overwrite the global $post object unless you specify with setup_postdata( $post ).

The easiest thing to do is to simply modify your metadata line and use:

$custom_meta_writer = get_post_meta( $post->ID, 'writer_meta_key', true );

Related Posts:

  1. Passing error/warning messages from a meta box to “admin_notices”
  2. Add “upload media” button in meta box field
  3. get registered metaboxes by post type or post ID
  4. How to get meta box data to display on a page
  5. esc before saving or before displaying does it matter?
  6. Add a meta description to home page?
  7. Check if meta key value already exists
  8. get_post_meta doesn’t work
  9. Metabox of one post influence setting on other
  10. How to store multiple input values with same meta_key
  11. Consolidate Metaboxes into 1 Big Metabox
  12. unable to save post meta on single field with multiple selects
  13. metabox upload file
  14. Why is variable value emptry in $_POST but available in $_REQUEST?
  15. Why does get_post_meta not work with the posts page?
  16. How to get meta box values – WP tuts tutorial
  17. Change the post date from a meta box
  18. update_post_meta and get_post_meta not working
  19. Repeatable custom meta fields
  20. how to save multiple checkboxes value in wordpress dynamically
  21. Using WYSIWYG In custom meta boxes
  22. Multiplicate entry on update_post_meta
  23. Undefined index error in custom post metabox
  24. Custom Meta box only returns most recent value on page
  25. How to prevent further updates of custom meta when using actions to set one meta based on another
  26. How to create a button click counter meta box?
  27. meta box & callback function
  28. $_GET & $post_ID
  29. get_post_meta as a list for drop down search filter
  30. Parse a text area custom meta box and assign as value to existing meta keys
  31. Getting metabox value?
  32. Hide Page Title with Post Meta
  33. Save meta data with post, Without using any plugin [closed]
  34. Editor meta box Showing but not saving
  35. How can i get multi checkboxes value in metbox?
  36. Show value of select dropdown in meta box
  37. remove a single post_meta
  38. Echo 2 values from one key in Array with get_post_custom
  39. save radio button selection in post-meta on submit
  40. post meta – problem : copy the same meta for all the articles
  41. Custom Meta Data is not being saved
  42. Update Post Meta in Front End with a form
  43. Update Post meta with custom variable
  44. update_post_meta doesn’t work
  45. Removing Meta Generator
  46. Only allow one meta key value per post in a category
  47. use post meta in add_meta_boxes action
  48. Custom meta box not saving values of radio buttons in WordPress
  49. Can’t save drop down select date in meta boxes
  50. update_post_meta does not work
  51. add_post_meta not saved
  52. when saveing $meta_box i get Undefined index error
  53. Updating post meta and Meta Box plugin
  54. Related posts and custom meta_box?
  55. Select Options Meta Data is Not Updating in Edit Meta Box
  56. How to display meta box data using “Meta boxes as needed”
  57. Metadata in loops
  58. Allow iframe in custom meta box
  59. Calling Data from Custom Meta Box
  60. How can i remove blank area caused by theme’s post meta boxes?
  61. Datepicker altField and altFormat to save a new meta key/value in a post?
  62. My meta box don’t want to save value
  63. CPT posts in drop downed in meta box on page doesn’t return post ID
  64. Create more Meta Boxes as needed
  65. Set Default Admin Screen options & Metabox Order
  66. How to set default screen options?
  67. Add a Meta Box for uploading a SECOND Featured Image?
  68. Does WordPress have a “Form API”?
  69. Metabox with checkbox is not updating
  70. How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
  71. What is the “Advanced” $context in add_meta_box?
  72. Removing panels (meta boxes) in the Block Editor
  73. Change The Title Of a Meta Box
  74. What is the index [0] for on post meta fields?
  75. WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
  76. How to make open/closed and hidden/shown metaboxes status saved on a per-post basis?
  77. How To Remove The “+ Add New Category” Link From A Category Metabox
  78. How can I create a taxonomy meta-box with search suggestions but no new terms input?
  79. Remove the Featured Image Meta Box
  80. Remove the Yoast SEO Post Metabox [closed]
  81. Best practices for meta box placement?
  82. Creating a metabox to upload multiple images
  83. How Does WordPress Remember Metabox Positions?
  84. Sample code for validating custom metabox?
  85. Post custom metabox textarea using wp_editor
  86. How to Add Reminders/Notes to New Post Meta Boxes
  87. How do I get attachment_id?
  88. Removing Metabox for “Slug” without removing functionality
  89. post formats – how to switch meta boxes when changing format?
  90. How to reorder meta box position?
  91. Prevent sorting and dragging of specific postbox metabox
  92. One metabox for multiple post types
  93. How can I retrieve multiple get_post_meta values efficiently?
  94. How do I position meta_box on post edit screen after the title?
  95. How to add a class to meta box
  96. Custom field metabox not showing in back-end
  97. Has anyone successfully integrated qtranslate with custom metaboxes?
  98. Put the media uploader in a metabox
  99. Custom Meta Boxes: multiple fields within a repeatable field
  100. Removing meta boxes: remove-meta_box() or unset()?
Categories metabox Tags metabox, post-meta
How to get_comments() ordered by date and parent?
Walker_Category – not reliably saving

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