you need a global $post;
within that function before trying to access the contents of $post.
Related Posts:
- How to get Custom Post ID by adding filter to child theme’s function
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Custom post status not working
- White screen error for a custom theme
- How do you output custom code between posts in the loop?
- Check Title Unique Or Not and If not error message and dont save
- How to customize a permalink (URL) structure?
- Cannot save CPT meta box
- Allow users to create posts without logging in?
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Add an Outside Wrapper to my Header and Make it Full Width
- Custom post type’s posts are not showing anywere but in xml sitemap
- post_content is stripping HTML when adding a new post? [closed]
- Post visibility option to theme front-end for author to select?
- Function to add custom HTML into head in custom post-type list page
- Custom Form / Search with Custom Post Type Data
- Stored meta from attachment, video length?
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- How to display *block number* instead *date value* on WordPress posts?
- Restrict custom post type to only site administrator role
- How to force one column layout on custom post type edit page?
- Search multiple custom fields by using meta_query
- Custom post type save_post action not firing
- Redirect after deleting post and keep track of pagination
- How do I add a custom post type to the Featured Content in twenty fourteen theme?
- remove_action conditionally for Custom Post Type
- WordPress custom post action hook
- Assigning a role to a specific custom post type (and ignoring other post types)
- Custom post type loops with different page templates
- Display posts in random post types
- Multiple Content Block
- Allow Users Access to Custom Post Type Only
- Using pre_get_posts to Filter Posts
- Remove “Get Shortlink” button in admin of custom post type
- Remove All, Published and Trashed Post Views in Custom Post Type
- When ‘is_post_type_archive()’ return true?
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php
- WordPress if in term*
- Create a post in custom post type using field in registration form after users submit form
- Weird problem happening with custom taxonmy when creating/updating posts
- right_now_content_table_end function not working?
- CPT: if more than X images are in post, use pagination
- Conditional Query of Custom Post Type and custom taxonomy
- How to target a specific custom post type post and its all children and grandchildren?
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Structure of data : CPT + terms
- Default text in a specific post type, but not visible?
- How to remove post listing page for a custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Add term to custom post type on draft
- Template not working for the custom Post type
- Loop increase number
- How to customize work area / admin area in a custom post type without plugins?
- Change Slug of a Custom Post Type
- Change “empty trash” button text?
- Move Genesis Single Page/Single Post Title
- why post_class() function apply css classes to all other files?
- Only show columns in custom post type?
- Show current user posts in custom post type query
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Display Custom Post Types Glossary
- Custom post type in Custom widget – $listItem
- Convert Custom Table Data Based Plugin To Be Searchable
- add_action ‘init’ from inside a class for custom post types
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Conflict in function to allow single post template based on category
- WP 3.1 custom post type permlinks
- Placing Admin Post Metaboxes in Tabs
- Why is my custom post content only viewable when signed into WordPress?
- Pagination not working in custom post type. Help
- Urgent – WordPress keeps creating posts
- Querying posts that don’t have a certain key value or don’t have the key
- ACF field check value of field on all other articles
- Problem with multi checkboxes value in metabox?
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Send mail to author when custom post type is saved
- Recovering data about custom post and taxonomy types
- wordpress does not see the correct custom taxonomy hierarchy
- is using “require_once” in wordpress theme affect the speed ???
- Multiple WordPress Sites, Same Database but Filtered Content
- Change Background Color For CPT Template
- Filter wp_dropdown_categories Per Post Type
- WP_Query function for custom post type
- Modify shortcode to work with custom taxonomies and slugs
- Calling the first & last post by category in custom post type
- Add Excerpt On Quicksand Plugin
- Custom post type adding additional markup
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Code in custom widget queries all posts, when it should only query the current post
- Add HTML before a specific div?
- How to make a template for a specific post of a custom post type?
- ACF select box css color change
- Creating post custom field text area
- How to make a non-public post on wordpress approval?
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- is therer any wordpress function to retrieve a specific html element from post content