Sometimes WordPress is criticized treating everything as a post
. The matter of fact is, post type pages
, post type post
– both are actually Post in database. So no post will collide with any page ID. 🙂
So simply a get_post_meta()
is enough.
But if you still want something specific to Pages, you can use:
if( is_page() ) get_post_meta(...);
Yes, you can use get_post_meta()
outside the loop. But instead of passing the post_id using get_the_ID()
you have to pass the post_id manually.
Related Posts:
- Problem with serialized arrays in custom meta
- explode array within shortcode
- Can I count the number of users matching a value in a multiple value key?
- WP doesn’t show Array Custom Fields?
- Add multiple images to a page sidebar
- How to delete custom field “suggestions” from dropdown list
- 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
- How to load php file for specific page in admin?
- How to set default metaboxes on user creation?
- Metabox nonce PHP notice
- Exclude custom post type from search by custom field value?
- ajax jquery update custom field meta value front end
- How to break meta values into different items and avoid duplicates?
- Add input field to ‘Pages > Edit Page’ through functions.php
- How can I query on the year part of a complete date in a custom field?
- get_post_meta not working inside loop
- How do I exclude posts by custom field value?
- How to display Meta Field Value?
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- What is the cleanest way to extract custom variables from a post
- Auto populate a meta box field from another meta box field when publish or save
- 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
- Order query by meta_value with multiple custom fields
- Display only past events on that page using Visual Composer Grid Bulider
- Accessing loop functions (e.g the_title or the_content) from post ID
- custom avatar removal
- user Profile meta value as custom field
- Send email with custom fields after new draft is saved or new post published
- Use WPbakery for own custom field [closed]
- Get posts with same meta value as current post
- Add custom field to all posts in specific post_type
- Change the sort order for posts to include custom field
- query posts custom field calculation value
- Get Data From wp_sitemeta for Multisite network
- Syntax Issue: How Do I Call A Custom Field Inside a ForEach Statement? [closed]
- Singleton Custom Field (Meta Box)
- Get categories query not working in function.php
- Displaying custom filed content instead of post content
- Hide custom fields when empty
- Save all the post tags inside a custom field
- How to add fields in custom registration form, validate it and aave to db? [closed]
- How to update a custom field in all posts with the value of another custom field in the same post?
- How add multiple wp_editor_box to new post
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- How to validation for sanitize_URL?
- How can I output the custom fields wrapping with HTML
- put saved metabox values back into fields and then display on the front end
- How to get custom image field of specific post id
- Custom field to array?
- How to sort by custom field value?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- wp_get_attachment_image_src() with advanced custom fields returning empty
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- Custom field bug in WordPress 3.2
- Change word in woocommerce product category custom field
- get posts based on non-single metadata
- Problem with revisions only returning four results
- Woocommerce products search with custom fields
- Convert author metadata to a custom field
- How to save multiple values with same meta_key, each value linked to another tag id
- Add forms dynamically in admin pages?
- Custom pages or Custom Posts
- get_avatar filter is not working as per requirement
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- how can i show WordPress custom field data to my short code?
- how to execute custom field for structured data?
- searching by keywords in post’s metas or pagination links problem
- Permanently show Custom Fields in Editor
- open modal window
- a lot of custom fields
- Hide custom fields by user’s role
- 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
- update meta field value after
- meta_query ‘compare’ => ‘!=’ not working
- If metabox fields has content display content
- Show comon custom field results?
- Display Data From This Custom Media Upload Meta Box?
- Custom fields and auto save
- Save values generated via API as custom meta fields
- Display Child Page with custom fields within Parent Page
- Load code for custom fields only on admin pages?
- Custom field in a shortcode?
- Exclude empty fields from custom field calculation (Average)
- Pagination not displaying correct number of pages
- Filter Query Post by Custom Fields(by date)
- Show/Hide Featured Image or replace it with custom field [closed]
- Dynamically update Custom Fields to display new dates
- save all acf options in one meta_value [closed]
- Can running a WP-Cron to update_post_meta cause performance issues?
- custom field value is blank or empty