You’re using $post->ID
, but haven’t defined $post
anywhere. You either need to specify global $post;
, to get the current post in the loop, or define it some other way. But the best way to get this ID would just be to use get_the_ID()
:
<?php $sub_heading = get_post_meta( get_the_ID(), 'sub_heading', true ); ?>
Related Posts:
- explode array within shortcode
- Change behavior of “Insert into Post” based on attachment metadata
- Add new “Insert Into Post” button with another function
- Call a custom field in an audio shortcode?
- wp_editor in add_meta_boxes does not show gallery
- Custom field for default gallery
- Execute/Parse Shortcode in Native WordPress Custom Field Value Field
- Audio player shortcode not showing up when using variable
- Create WordPress shortcode with php code inside
- Display WP-Types custom fields in post [closed]
- Should custom meta boxes be able to output shortcodes the same as WordPress’ native post editor?
- Shortcode To Display Post Custom Field Value Inside Excerpt
- modify wordpress caption shortcode
- How to create a shortcode to print specific values stored in a post meta array?
- Insert a custom field into a shortcode and use it in post(s)
- Custom wysiwyg editor doesn’t execute shortcodes?
- Custom Field 101
- shortcode in a custom metabox
- Can data from a Custom Field data be used by a shortcode on a per page/post basis?
- Shortcode To Display Post Custom Field Value in Post Title, Post Content
- custom field (video/audio url) and embed functionality
- IF Custom field value equals ZERO
- Display MP3 as media using an URL from a custom field
- Using a custom field inside a shortocde
- Enable a short code in the custom meta field
- do_shortcode close
- Plugin or shortcode for ISBN number?
- How to pass custom field value to shortcode?
- Replacing custom field with shortcode
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- Search fails when using the radio buttons
- Create Shortcode shows only posts with custom_field meta
- Output Custom Field value to shortcode
- PHP and Shortcode Combination
- Stop truncation of shortcodes in custom text fields?
- Retrieving Advanced Custom Field within Shortcode Function [closed]
- Using ACF Custom Field value in a URL with do_shortcode() [closed]
- Running a Gallery Shortcode in a Custom Fields Widget
- Custom field in a shortcode?
- Display meta data from a custom field within plugin Category Grid View Gallery
- Insert wp gallery shortcode into custom textarea
- Displaying shortcode content inside custom field without images
- Parse Shortcodes in Theme’s Custom Field?
- Insert shortcode before and after a list automatically
- Retrieving custom field as shortcode
- Custom fields doesnt work well with any postTAB plugin
- How to include custom field in shortcode (do_shortcode) in theme file
- Shortcode not picking up custom field
- Problem with serialized arrays in custom meta
- WP doesn’t show Array Custom Fields?
- How to save custom fields for attachments
- How to get a meta value from all post
- Adding existing user custom field value to a woocommerce product [closed]
- How to save values of a custom input field on the Network > Site Info screen
- Exclude custom post type from search by custom field value?
- get_post_meta not working inside loop
- add meta box using function.php
- How do I exclude posts by custom field value?
- wp_query add arguments using array_push if variable met
- How do I use wp_query for WordPress search?
- Nav Menu – Add class based on meta keys
- Eliminating the appearance of a specific custom field in a post
- Conditional custom field query
- Display two custom values from a post
- Find page IDs with specific meta tag key value pairs
- Accessing loop functions (e.g the_title or the_content) from post ID
- custom avatar removal
- Send email with custom fields after new draft is saved or new post published
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Get posts with same meta value as current post
- query posts custom field calculation value
- Efficiently sort only certain categories by custom field
- How can I do a variable for meta_query?
- Singleton Custom Field (Meta Box)
- Displaying custom filed content instead of post content
- Save all the post tags inside a custom field
- How to update a custom field in all posts with the value of another custom field in the same post?
- Set featured image from custom field URL
- Best Way to get facebook share count and update using wp_schedule_event or any other method
- Get YouTube video id from url in a custom field
- Filter posts by custom field (Advanced Custom Fields)
- Trying to implement AJAX into my admin pages. Am I improperly enqueue and localizing my scripts?
- WP E-Commerce Custom Meta > Serialized array
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- How do I upload file through custom field, save it to database and get it
- Custom meta fields and meta keys
- HTML for adding a meta box (basic text field) to page editor?
- Block error message in foreach loop when looping through ACF field
- Save Taxonomy of Post via custom Taxonomy Select Dropdown
- how to execute custom field for structured data?
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Retrieve Google API JSON data and store as WordPress Custom Fields
- meta_query ‘compare’ => ‘!=’ not working
- Why WordPress takes time to make request to save post?
- Show comon custom field results?
- Display Data From This Custom Media Upload Meta Box?
- Display Child Page with custom fields within Parent Page
- Pagination not displaying correct number of pages
- Show div based on custom meta value
- Show/Hide Featured Image or replace it with custom field [closed]