As for the code. You will need to add in the ‘posts_per_page’ arg and set it to -1.
This should fit the 5 post limit issue.
As for the code, it looks great.
If you turn the get_posts into a WP_Query, you can then debug the actual SQL. This will help to spot any issues in the SQL.
You can do this like so:
<?php $artworks = new WP_Query(array(
'post_type' => 'artworks',
'meta_query' => array(
'key' => 'artist', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
I was able to get the query to work by removing the quotes from the value param as such:
'value' => get_the_ID(), // dropped the quotes around the value since its a number
Hopefully this doesn’t cause other issues, but I’m glad it’s working. Any thoughts on why it’s different from your code? Perhaps you can explain further why the quotes were there in the first place. Have you seen issues arise with false positives?