Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Display custom post type from dynamic custom field

Try changing $meta['title'] to $meta['title'][0] & the same thing for $meta['track'] . change it to $meta['track'][0]

UPDATE:

I looked at the code more deeply and you basically need a foreach loop.
Here’s the final code should look like:

<?php
$args = array(
    'post_type' => 'page'
);  
$repeat_loop = new WP_Query( $args ); if ( $repeat_loop->have_posts() ) : while ( $repeat_loop->have_posts() ) : $repeat_loop->the_post();
$meta = get_post_meta( $post->ID, 'songs', true ); ?>                  

<?php
foreach ($meta as $key => $value) {
    echo $value['title']; ?><?php echo $value['track'];
}
?>
<?php endwhile; 
    endif;
    wp_reset_postdata(); 
?>

Thanks

Related Posts:

  1. Use WP_query to match post types based on custom field values
  2. WordPress custom post type
  3. Query all posts where a meta key does not exist
  4. what is the correct way to compare dates in a WP query_posts meta_query
  5. Meta query with boolean true/false value
  6. Get post with multiple meta keys and value
  7. Custom post type archive 404’s with paginate_links
  8. Display Custom Post Type Fields
  9. Retrieving 3 latest post from each of 5 different custom post types
  10. how to group custom post type posts by custom taxonomy terms
  11. Using Query Posts With Multiple Post Types And A Taxonomy
  12. How to get the parent’s taxonomy?
  13. How Do I Use WP_Query to Run This Database Query as Search Result?
  14. Can’t sort order of wp_query with 2 meta keys
  15. Query for posts from any post type but only add instock products
  16. Query not returning CPT posts
  17. Unable to display multiple post types in same query (WPML WP_Query)
  18. Query for posts in 2 taxonomies
  19. Quickest way to get last or oldest post date – WP Query
  20. Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
  21. Separate Posts and Custom Post Type in Custom Taxonomy archive template
  22. Custom query shows custom post types in trash
  23. Multiple post type queries (with specific arguments for each)
  24. WordPress Orderby Numeric Value Not Working
  25. Sorting multiple custom post types without a meta key/value pair by sort order
  26. orderby in custom WP Query does not work
  27. Query/list all terms and their custom post count
  28. Archive for custom taxonomy lists all posts instead of current taxonomy
  29. Get posts between custom dates
  30. Get latest 3 posts from multiple CPT in one query
  31. Polylang non-default language ignores tags in WP_Query
  32. WordPress request fiter order by related post’s post_title
  33. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  34. Different Ways to Query Custom Post Types?
  35. pagination not working for category.php (custom post types in categories)
  36. How to display Related Posts based on number of taxonomy terms matched
  37. Filter date from post meta when date is in string format
  38. How to make WP_Query not to show irrelevant posts?
  39. Loop for custom post types filtered by a taxonomy
  40. Displaying a div from an assigned meta_value when on a page
  41. How to get specific post meta by title or id
  42. Custom post type, custom taxonomy, query posts only from taxonomy (children of)
  43. Pagination not working on custom query on a page
  44. find custom post type post by searching its custom field with my string
  45. FacetWP paging custom wp_query
  46. $post->post_meta not pulling any post in wordpress/php
  47. WP_Query of custom post type sorted by meta_key has unexpected results
  48. Returning a custom content types with meta values
  49. Can’t change posts per page in WordPress Post Type Query
  50. postsperpage value not being applied
  51. WP_Meta_Query object with conditionals
  52. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  53. HM CMB: Post Select Field for CPT ID
  54. Custom Post Type Query W/Category Dropdown
  55. Find Posts based on Child Post value
  56. Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
  57. Sorting the Loop by Taxonomy Value
  58. Custom Query: Multiple CPTs and a taxonomy filter
  59. WP query_posts group by meta field related
  60. Custom wp-query display post only today
  61. After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
  62. custom post type and a “sticky” position taxonomy
  63. How to sort by multiple values in a nested WP_Query
  64. Custom meta fields not showing up in WP_Response Object via custom endpoint
  65. How to get post by meta value
  66. How do I get all authors posts of a custom post type outside loop
  67. minimize wp_query call to database
  68. Linking posts together with Advanced Custom Fields “both ways”
  69. Query the title of the page to show posts with matching category in the loop
  70. update a posts of other custom post type
  71. How to get Current week and current date record wp query
  72. How to get post meta for custom post type and taxonomy
  73. get_post_meta for Custom Post Type ( CPT )
  74. Main site single-property.php design, as homepage of a multisite
  75. Imported Content Doesnt Show Up On Frontend
  76. display news with pictures 3 small and one large (loop)
  77. Custom Post Type meta oembed html output resulting in WSoD
  78. Values inside a custom field to determine which category posts to display
  79. Custom Query With Multiple Meta Key Value
  80. Custom post type blog pagination conflict
  81. Query Posts From Multiple Post Types
  82. Return only custom post types for the page, not all
  83. send user to first page of results when reposting to page?
  84. Querying meta values within an array
  85. How do I correctly query posts from a post ID?
  86. How to exclude certain portfolios from a loop
  87. Quering array of post types & pagination. Articles are repeating sometimes on different pages
  88. Display ACF object field data using Elementor Custom Query
  89. Assign a tag to custom post type using a query
  90. Quering a post object based on another related post object
  91. Query custom post type with tags
  92. How to check if user meta field is empty in conditional else statement
  93. Display only one post each WEEK
  94. wp_query check if integer exists in custom field’s array
  95. How to set YouTube video as featured image?
  96. convert custom query to wp_query
  97. List children on child post
  98. Wrong request query on cpt and tax
  99. Notice: Undefined index: error and understanding wordpress
  100. Previous/Next Link by Meta Value in CPT
Categories custom-post-types Tags custom-post-types, post-meta, query-posts, wp-query
Remove meta description on certain pages
add_image_size for header_image

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress