Title: getPressed's Replies | WordPress.org

---

# getPressed

  [  ](https://wordpress.org/support/users/getpressed/)

 *   [Profile](https://wordpress.org/support/users/getpressed/)
 *   [Topics Started](https://wordpress.org/support/users/getpressed/topics/)
 *   [Replies Created](https://wordpress.org/support/users/getpressed/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/getpressed/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/getpressed/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/getpressed/engagements/)
 *   [Favorites](https://wordpress.org/support/users/getpressed/favorites/)

 Search replies:

## Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] CPT Titles as Select Options in Forminator form](https://wordpress.org/support/topic/cpt-titles-as-select-options-in-forminator-form/)
 *  Thread Starter [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cpt-titles-as-select-options-in-forminator-form/#post-14978522)
 * Thanks, Patrick. This solves the problem with the options added programmatically
   not saving; really helpful!
 * I’d need to get a better handle on how to use $model_id to target this behaviour
   at specific forms, but I think the ideal approach would be to use a class to 
   flag fields that this should apply to, so that it can be set through the Edit
   Form ui in the dashboard.
 * I know it’s possible to add a class to a field’s container using Edit Field >
   Styling, the “Additional CSS Classes” setting. Is it possible to target this 
   behaviour that way?
 * Thanks again for your help above. I’ve seen a couple of other users ask this 
   question elsewhere without getting a solution, so really appreciate the code 
   you provided.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] CPT Titles as Select Options in Forminator form](https://wordpress.org/support/topic/cpt-titles-as-select-options-in-forminator-form/)
 *  Thread Starter [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/cpt-titles-as-select-options-in-forminator-form/#post-14976688)
 * Thanks for the response. Here’s the code I’m using:
 *     ```
       <?php
       /**
       * Plugin Name: [Forminator Pro] - Bulk add options to a Select field
       * Plugin URI: https://premium.wpmudev.org/
       * Description: Bulk add options to a Select field (as of 1.12.1.1)
       * Author: Alessandro Kaounas @ WPMUDEV
       * Author URI: https://premium.wpmudev.org/
       * Task: 0/11289012348292/1172200210290038
       * License: GPLv2 or later
       */
   
       if ( ! defined( 'ABSPATH' ) ) {
       	exit;
       }
   
       // No need to do anything if the request is via WP-CLI.
       if ( defined( 'WP_CLI' ) && WP_CLI ) {
       	return;
       }
   
       if ( ! class_exists( 'WPMUDEV_Forminator_Bulk_Select_Options' ) ) {
   
           class WPMUDEV_Forminator_Bulk_Select_Options {
   
               // User defined settings
               private $form_id    = 1080;
               private $field_id   = 'select-1';
   
               // User defined options
               private $options = array(
                   'none'    => 'None',
               );
   
               private static $_instance = null;
   
               public static function get_instance() {
   
                   if( is_null( self::$_instance ) ){
                       self::$_instance = new WPMUDEV_Forminator_Bulk_Select_Options();
                   }
   
                   return self::$_instance;
   
               }
   
               private function __construct() {
   
                   if ( ! defined( 'FORMINATOR_VERSION' ) || FORMINATOR_VERSION < '1.12' ) {
                       return;
                   }
   
                   $this->init();
   
               }
   
               public function init(){
   
                   add_filter( 'forminator_before_form_render', array( $this, 'wpmudev_forminator_before_form_render' ) );
   
               }
   
       				public function wpmudev_forminator_before_form_render( $id ){
   
       					if( $this->form_id != $id ){
       						return;
       					}
   
       					$post_type_query  = new WP_Query(
       						array (
       							'post_type' => 'club',
       							'posts_per_page' => -1,
       							'orderby' => 'title',
       							'order' => 'ASC',
       							),
       						)
       					);
       					$posts_array = $post_type_query->posts;
       					$post_title_array = wp_list_pluck( $posts_array, 'post_title', 'ID' );
   
       					$i = 0;
       					foreach( $post_title_array as $key => $value ){
       						$post_title[] = $value;
       						array_push($this->options, $post_title[$i]);
       						$i++;
       					}
   
       					add_filter( 'forminator_field_markup', array( $this, 'wpmudev_forminator_field_markup' ), 10, 2 );
       				}
   
               public function wpmudev_forminator_field_markup( $html, $field ){
                   if( $field['element_id'] === $this->field_id ){
                       $markup = '';
                       foreach( $this->options as $key => $option ){
                           $markup .= '<option value="' . $key . '" data-calculation="0">' . $option .'</option>';
                       }
                       return str_replace( '</select>', $markup . '</select>', $html );
                   }
                   return $html;
               }
   
           }
   
           add_action( 'plugins_loaded', function(){
               return WPMUDEV_Forminator_Bulk_Select_Options::get_instance();
           });
   
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP WooCommerce Mailchimp] GDPR: Opt-in checkbox is checked by default](https://wordpress.org/support/topic/gdpr-opt-in-checkbox-is-checked-by-default/)
 *  Thread Starter [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/gdpr-opt-in-checkbox-is-checked-by-default/#post-9865862)
 * Thanks. 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Newsletter Meenews] [MeeNews] Fatal error: Cannot access private property PHPMailer](https://wordpress.org/support/topic/meenews-fatal-error-cannot-access-private-property-phpmailer/)
 *  Thread Starter [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/meenews-fatal-error-cannot-access-private-property-phpmailer/#post-2193316)
 * With some help from the plugin author, we’ve now got this working.
 * Thanks Daniel…
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [If no featured image, show image from post](https://wordpress.org/support/topic/if-no-featured-image-show-image-from-post/)
 *  [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [15 years ago](https://wordpress.org/support/topic/if-no-featured-image-show-image-from-post/#post-2202533)
 * One thing to watch with that: Because you haven’t specified a ‘post_mime_type’,
   get_posts could retrieve an attached PDF, which would mess things up.
 * Tim
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [If no featured image, show image from post](https://wordpress.org/support/topic/if-no-featured-image-show-image-from-post/)
 *  [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [15 years ago](https://wordpress.org/support/topic/if-no-featured-image-show-image-from-post/#post-2202465)
 * You can use [has_post_thumbnail()](http://codex.wordpress.org/Function_Reference/has_post_thumbnail)
   to check for a featured image.
 * If that returns false, then you can use [get_children()](http://codex.wordpress.org/Function_Reference/get_children)
   to retrieve images attached to the Post (N.B. that isn’t quite the same thing
   as being included in the post content).
 * First load the attachments into a variable with `$imageAttachments = get_children('
   post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment','
   post_mime_type' => 'image')`, then check whether $imageAttachments is empty and
   act accordingly (if it is show a default image, and if it isn’t display the first
   attached image at the appropriate size).
 * Of course, you’ll also need to define the thumbnail size (see [add_image_size()](http://codex.wordpress.org/Function_Reference/add_image_size)).
 * Tim
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Newsletter Meenews] [MeeNews] Fatal error: Cannot access private property PHPMailer](https://wordpress.org/support/topic/meenews-fatal-error-cannot-access-private-property-phpmailer/)
 *  Thread Starter [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [15 years ago](https://wordpress.org/support/topic/meenews-fatal-error-cannot-access-private-property-phpmailer/#post-2193241)
 * Not quite fixed yet, but we’re getting there.
 * Will post back when we have this working.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to get term ID](https://wordpress.org/support/topic/how-to-get-term-id/)
 *  [getPressed](https://wordpress.org/support/users/getpressed/)
 * (@getpressed)
 * [15 years ago](https://wordpress.org/support/topic/how-to-get-term-id/#post-1660277)
 * Just a small typo to fix (“taxonomy” instead of “texonomy”):
 * > $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’));
   > print_r($term);

Viewing 8 replies - 1 through 8 (of 8 total)