I can’t separate the array by commas

implode(“,”, [500,756]) will definitely return “500,756”, therefore you have some other problem. If the field type of the ‘num’ field is a numeric type such as MySQL’s INT, then MySQL or PHP might try and convert this string to a number and so “500,756” could become 500. Check the data type of the ‘num’ field … Read more

Display featured image of post type category

The immediate answer to your question is that you can just add a category ID to the query_posts() call, e.g.: query_posts(‘orderby=rand&showposts=1&post_type=gallery&cat=10′); Slightly longer answer is that it’s not a good idea to use query_posts in themes and plugins. More info in the docs here: https://developer.wordpress.org/reference/functions/query_posts/ You might want to take the opportunity to change the … Read more

Remove duplicates from echo output in PHP [closed]

This is more of a PHP programming question than specific to WordPress, but you could do something like this. This keeps a track of which colors have been shown in $shownColors array and doesn’t show the same one twice. function loop_display_variation_attribute_and_thumbnail() { global $product; if( $product->is_type(‘variable’) ){ $shownColors = Array(); foreach ( $product->get_visible_children() as $variation_id … Read more