my goal is to list all checked attachments(images) in random order on home page with link to parent post.
I put this in attachments.php:
<br /> 'home' => stripslashes( $data['home'] ),<br />
in array_push( $post_attachments, array... and this in $attachment_details = array :
<br /> 'home' => str_replace( '"', '"', $_POST['attachment_home_' . $i] ),<br />
And this for control in admin.
<br /> <input type="checkbox" id="attachment_home_<?php echo $attachment_index; ?>" default="0" name="attachment_home_<?php echo $attachment_index; ?>" value="1" <?php if ( 1 == $attachment['home'] ) echo 'checked="checked"'; ?> /><br /> <label for="attachment_home_<?php echo $attachment_index; ?>"><?php _e("Home", "attachments")?></label><br />
Everything above work in admin, checked boxes stay checked, it write value "1" in database if checked for 'home'.
My problem is to list all attachments with value "1" on homepage with link parent post.
I try with get_posts() , but everything works good for all attachments but I cant figure out how to filter attachments with "_attachments" meta key value 'home' = 1
I understand that 'home' value is serialized in "_attachments" but how to unserialize and use that value is where I fail.
Can anyone help me with that please?