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
- Advanced search form with filters for custom taxonomies and custom fields
- meta_query for keys that aren’t yet set
- Enable sticky posts to custom post_type
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- How do I Paginate Search Results for Custom Post Types?
- How can I add a column/s to wp_posts table?
- Ordering posts having multiple post-meta date fields
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How to hook get_terms() to only show count of posts that have custom meta
- I can’t set meta_key in my custom post type query
- order by meta_value serialized array
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- add_meta_box: Datepicker like the one for postdate?
- How loop through posts based on custom fields
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Display custom post types with custom date field value (before today) & order by custom date field
- What Is meta_id In wp_postmeta?
- Create a random unique 6 digit number as custom field for custom post type
- how to interconnect custom post types?
- WordPress Orderby Numeric Value Not Working
- meta_query compare >= not working but
- List all images from a single post meta value
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- WP_Query: include custom post type only with specific meta value
- Show the same Article Available in Other Categories
- Meta Key Value in current-user-only loop
- wp_query check if integer exists in custom field’s array
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- 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
- 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
- Update postmeta Parent when post_status child change
- 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
- Possible to filter custom post type with multiple meta data?
- filter search custom field query
- How to let users choose where to search for posts?
- Custom fields for custom post type
- Check if post with same meta value exists
- 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
- WP_Query of custom post type sorted by meta_key has unexpected results
- copy images from custom field to another custom field
- Custom Query: If One Post Object Field Value Is The Same As Another
- Modify Posts from Custom_Post_Type within the plugin
- Cannot obtain custom meta information
- 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
- 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?
- Custom fields for post or terms which don’t update on post update
- order the meta query results by 2 custom fields
- 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
- Meta query and compare “!=” not working as expected
- 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
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Meta_Query refuses to return results
- 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
- Delete custom post type metadata without deleting the post in admin area
- How to add post reference field to a plugin?
- Edit post meta direct from post.php?
- Unable to get the upcoming events for custom post
- How to create content automatically when a post is published?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Get Posts ordered by a date custom meta field
- Function to Compare CPT Post Custom Value with Default Posts CF Value
- Display code if title of the custom post matches title of other post