wordpress - Php - get_option - Search for specific Options -
i trying search specific options (my_option_…) , print them in rows.
i have been testing things while , cannot find solution. using (search_terms=my_option_) seems not work.
is there easy way implement this?
<?php add_option('my_option_1', 'option 1'); add_option('my_option_2', 'option 2'); add_option('my_option_3', 'option 3'); ?> <?php $option1 = get_option('my_option_1'); $option2 = get_option('my_option_2'); $option3 = get_option('my_option_3'); if ( get_option('search_terms=my_option_')){ //??? echo "multiple found!!"; while(get_option('search_terms=my_option_')) { echo "options"; //??? } } if ( get_option('my_option_2')){ echo "my_option_2 found!!"; } ?>
$query = " select option_name $wpdb->options option_name 'my_option_%' "; $my_options = $wpdb->get_col($query); if(!empty($my_options)) { echo "multiple found!!"; foreach ($my_options $my_option) { echo get_option($my_option); } }