From 12acab05c34c9632fb8054cf9d1045490497377f Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 11 Apr 2024 11:06:54 +0200 Subject: [PATCH] handlign custom prefill for paper brochure form --- functions.php | 1 + includes/forms.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 includes/forms.php diff --git a/functions.php b/functions.php index bdb682d..12325b1 100644 --- a/functions.php +++ b/functions.php @@ -15,3 +15,4 @@ require_once(__DIR__ . '/includes/api.php'); require_once(__DIR__ . '/includes/wysiwyg.php'); require_once(__DIR__ . '/includes/search.php'); require_once(__DIR__ . '/includes/rooting.php'); +require_once(__DIR__ . '/includes/forms.php'); diff --git a/includes/forms.php b/includes/forms.php new file mode 100644 index 0000000..f4a6191 --- /dev/null +++ b/includes/forms.php @@ -0,0 +1,38 @@ +type != 'checkbox' || strpos($field->inputName, 'publication-list') === false) { + continue; + } + + // you can add additional parameters here to alter the posts that are retrieved + // more info: http://codex.wordpress.org/Template_Tags/get_posts + $brochures_query = new WP_Query(array( + 'post_type' => 'brochures', + 'posts_per_page' => -1, + 'post_status' => 'publish', + )); + + // $posts = get_posts('numberposts=-1&post_status=publish&post_type=brochures'); + + $choices = array(); + + foreach ($brochures_query->posts as $post) { + $choices[] = array('text' => $post->post_title, 'value' => $post->post_title); + } + + // update 'Select a Post' to whatever you'd like the instructive option to be + $field->placeholder = 'Select a Post'; + $field->choices = $choices; + } + + return $form; +}