You need to use get_post_meta
:
get_post_meta( $post_id, $key = ”, $single = false )
Retrieve post meta field for a post
$post_id (int) (Required) Post ID.
$key (string) (Optional) The meta key to retrieve. By default, returns data for all keys. Default value: ”
$single (bool) (Optional) Whether to return a single value. Default value: false
eg.
echo get_post_meta( $post->ID, 'the-name-of-key', true);
When using true
, you will get a string
, but if you use false
instead, you will get an array
.
Related Posts:
- Adjust the results quantity for Search Results page pagination
- Custom search results page not working with empty search
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- Search not showing all results
- Autocomplete search box
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- edit search.php to include subdomain posts
- Search Query: how to construct a search string from two select elements?
- How can I edit the content in index.php? [duplicate]
- Can anyone offer any help with this function?
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Show a different code on front page to other pages
- Does wordpress templates always in files or in database?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- How to get all author posts outside of author templates
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- WordPress template page name displayed on screen
- Search WordPress using static html page
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Exclude posts with specific metadata from search?
- Use Tags to initiate Search
- Search form does not work in my website
- single.php with different look by category
- How to call multiple functions from multiple files into a WordPress page template [closed]
- How do I define a lookup table that will work across all PHP elements of the template?
- persist a variable set in header.php all the way down to footer.php
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Removing WordPress Footer -without access to PHP code?
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- How to set a template with wp_insert_post
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Why does the Woocommerce grouped template prints the unpublished products?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- Form search query – displaying ACF “Post Object” field as results
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- add_filter function concatenate string and locate_template function
- How to render a block from php template
- Template Loop – add switch case php
- Override Admin menu icon
- List post by title length
- Post repeated when opening in overlay, how do I solve this? [closed]
- How to suppress template-parts in undescores?
- Need help with pagination
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Creating custom page template from existing PHP site
- How do I remove duplicate users from two merged WP_User_Query objects?
- Searching Posts Programmatically in a WordPress Plugin
- Conditional string comparison failing for basename/slug
- Search only working on front page (index) , not working on other pages
- Live search from database table
- Splitting the_content() by size?
- Gravity Forms merge tags in templates?
- Unable to render custom field after attempt to generate a list of recent post in page template
- How to add new CSS file to new PHP file
- WordPress Search
- WordPress pagination not working in search result page
- Search page results conflicting logic – Search result caching?
- php loading different structure than source code
- pass html code to worpdress
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Search.php gets metadata from first post
- Getting a WordPress tag to print inside of a traditional php echo
- search and add in wordpress content
- How can I modify this code to make the search box include tags and meta
- Validate search against a list of codes in wordpress
- Free search and custom taxonomy query not providing the same result
- search.php to search only the post title
- Display WordPress search results based on the selected Sub-Category
- WordPress Search Ajax + Isotope + InfiniteScroll
- Loading Elementor templates in a Bootstrap modal on button clicking
- how can i include post meta in search result
- Highlighting Text in Search Results
- My worpress search page is showing no results
- Replace a single variable with add_filter
- Build A Custom SQL Query for WordPress Search
- Include custom fields in search
- Prevent header and footer from loading on specific pages with template or plugin
- Using a new WP_Query inside the loop
- Require()/Include() post template adding extra content
- How to search order using database frontend short code WordPress
- Display articles with a different template in the home page | Solved |
- Change ajax live search results
- Display metabox galleries on specific page template in admin editor
- meta_query search names when they have middle initials
- Display WordPress archive template page in 3 columns and not 1 column [closed]