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?
- How to correctly submit a search form and display the result in an independent page
- Displaying a WooCommerce product via PHP
- Get the php template file from other theme folder
- How to exclude pages from the search results
- Easy way to process search results before displaying
- How to find objects by terms
- wp_remote_get returns an error for valid URL
- How can i display 3 post types in same page?
- Unable to set right time in admin and frontend template
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Can I use HTTP POSTs? Is there a better alternative?
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- Custom field value not saving when it contains a URL?
- Automatically add custom CSS to new posts using a category template
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- creating a second image attachment template?
- How to show single category archive
- Issues getting PHP to display in category pages
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Seach custom post type posts only by meta fields?
- Search not showing all results
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Show a different code on front page to other pages
- Does wordpress templates always in files or in database?
- Adding wrapper elements in the_date() like in the_title()?
- How to get all author posts outside of author templates
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Search form does not work in my website
- 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
- Why does the Woocommerce grouped template prints the unpublished products?
- 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
- Override Admin menu icon
- List post by title length
- How to suppress template-parts in undescores?
- Need help with pagination
- Splitting the_content() by size?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Search.php gets metadata from first post
- search and add in wordpress content
- Loading Elementor templates in a Bootstrap modal on button clicking
- Build A Custom SQL Query for WordPress Search
- Include custom fields in search
- Using a new WP_Query inside the loop
- Display articles with a different template in the home page | Solved |
- What are the advantages/disadvantages of ways to use php template files?
- Change the “Show All” button in a WordPress Portfolio Filter
- Check if current post in loop is last on current page
- Help me understand how Search function works using dynamic_sidebar()
- Converting Array to String Issue [closed]
- ACF – Custom image for Product Tags not displaying
- Roots Sage Symfony error when using override from template
- Searching a custom WP table and displaying results in an HTML table
- Search only for posts with specific metadata?
- What syntax is this? “{{post.price}}”
- My search results are only showing 5 posts?
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- How can I include tags in wordpress search without a plugin
- How can you disable search for non-members on your WordPress website.
- Search results template listing all posts
- Search bar for page that searches only particular page IDs
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- Access methods in plugin template
- Limit Search Queries per IP per Day
- Create dynamic content from one WP page to multiple other pages
- Different layout on search page depending on category post
- why is this content-template not showing any of my blog-entries?
- Search box background on a different page template
- Search through documents folder
- PHP code rendered in HTML
- get_permalink returning first letter
- split searchresults into different topics?
- Custom Archive Page
- If I define a variable in header.php, how do I make it available to templates?
- Search result page – display values from the result’s metaboxes
- php “use” not working in template [closed]
- Twig+WordPress how to use array arguments inside a function?
- The search doesn’t work properly
- How to make WordPress search.php display all strings found on pages or posts
- How can one use variables in a template or template part without polluting the global scope?
- Search custom post type posts only by meta fields?
- Limit a search box by CPT + taxonomies, in only one page
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)