Skip to main content
10 events
when toggle format what by license comment
Jul 3, 2021 at 6:39 vote accept Mathieu Préaud
Jul 2, 2021 at 20:33 answer added phatskat timeline score: 2
Jul 1, 2021 at 20:15 comment added vancoder Say hello to the ternary operator: $this_file = ! empty( $filearray['url'] ) ? $filearray['url'] : ''
Jul 1, 2021 at 16:53 comment added Mathieu Préaud I think I found a solution. Let me know if I'm wrong or right: if ( isset( $filearray ) && '' !== $filearray ) : $this_file = $filearray['url']; endif;
Jul 1, 2021 at 16:33 comment added Mathieu Préaud I understand, it's logic. However I'm struggling to resolve the issue. I'm starting in PHP so I block easily on this kind of problem.
Jul 1, 2021 at 15:56 comment added Jacob Peattie Ok, so think this through. When you create a new post, that post is not going to have this file, right? So how can ['url'] inside $filearray exist?
Jul 1, 2021 at 15:53 comment added Mathieu Préaud @JacobPeattie I edited the question by providing the full code.
Jul 1, 2021 at 15:52 history edited Mathieu Préaud CC BY-SA 4.0
added 2027 characters in body
Jul 1, 2021 at 15:43 comment added Jacob Peattie Where is wp_custom_attachment() used? Is the current post always going to have a wp_custom_attachment field saved? Your code doesn't handle the possibility that there's no value. And if there is a value, what does it look like?
Jul 1, 2021 at 15:38 history asked Mathieu Préaud CC BY-SA 4.0