This issue has been solved by changing the code that displays posts a little.
<?php
$albumsongs = get_posts( array('post_type' => 'song', 'numberposts' => -1, 'meta_key' => 'select_song_album', 'meta_value' => get_the_ID(),) );
foreach( $albumsongs as $post ){
setup_postdata($post);
?>
<div>
<span><?php the_title(); ?></span> <span><a href="https://wordpress.stackexchange.com/questions/352340/<?php the_permalink(); ?>">View</a></span>
</div>
<?php
}
wp_reset_postdata();
?>
Related Posts:
- How Can I save multiple records in same meta key?
- Update Post Meta for a logged in user
- Two Custom Post Types Many to Many Relationship
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Querying meta values within an array
- Check for custom field value in different post type than current one and do something
- Populate Custom Fields in a Custom Post Type?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Show the same Article Available in Other Categories
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- How to check if user meta field is empty in conditional else statement
- wp_query check if integer exists in custom field’s array
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- Get posts between custom dates
- How to implement a Google map store locator
- Post image in WordPress not appearing on home page
- Meta query for custom post type ignored in main query
- Posting to a Custom Post Type from front end – user generated content
- Add custom field to Posts and sort by it
- A better way to add a meta box to custom post types
- get_post_meta not working on publishing
- Meta Query Not Returning Output Despite Having Matching Values
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Update postmeta Parent when post_status child change
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- How to Output which matched meta_keys were found from custom_type_posts?
- Possible to filter custom post type with multiple meta data?
- Importing Data from a Non-WordPress database, into WP
- filter search custom field query
- How to let users choose where to search for posts?
- Query based on custom fields start and end date
- Custom fields for custom post type
- Check if post with same meta value exists
- Submitting Custom Post Types with custom fields from Front-end form
- create custom meta box with default value
- delete_post_meta() for whole CPT / multiple posts?
- How to get specific post meta by title or id
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query of custom post type sorted by meta_key has unexpected results
- Batch Extract Date from post title and put into ACF custom field
- copy images from custom field to another custom field
- Custom Query: If One Post Object Field Value Is The Same As Another
- How to show custom field on specific custom post type posts only when filled
- Modify Posts from Custom_Post_Type within the plugin
- Cannot obtain custom meta information
- How can I output WPAlchemy repeating fields meta values in my page template?
- How to call a post’s metadata in shortcode.php?
- WP_Meta_Query object with conditionals
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- updating one custom meta field only
- Add a class to post_class if more than one post shares same meta_value_num
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Front-end Image Upload to Custom Meta Box
- Filter search posts by post meta?
- Checking for custom field in admin pages
- A sports wordpress website
- Custom fields for post or terms which don’t update on post update
- Display custom post front end filter by ACF equals current user
- order the meta query results by 2 custom fields
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Get_post_custom not fetching value from array wordpress
- Add a form in every post and save data in post meta
- SELECT custom post type and its meta in SQL
- Using OR relation in meta_query to check for a value before sorting by another
- Save data is post using php front end
- How to display custom field in product description?
- How to keep custom post type related information
- Meta query and compare “!=” not working as expected
- Orderby if between two meta fields
- Use WP_query to match post types based on custom field values
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Where is get_post_meta value located?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- Add more custom fields when creating a new custom post type
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- update a posts of other custom post type
- How do I extract the contents of a CPT’s custom field for all posts?
- Query events post type after current date and timezone