Admin Options page. Save as Array

You only need to register one setting and then just modify your form inputs to save the values into an array. Here’s an example of registering the setting: register_setting( ‘mytheme_settings’, ‘mytheme_settings’, ‘admin_options_sanitize’ ); $mytheme_settings = get_option( ‘mytheme_settings’ ); and the field markup: <textarea name=”mytheme_settingsAdmin Options page. Save as Array”> <?php echo esc_textarea( $mytheme_settings[‘title’] ); ?> … Read more

Displaying theme options in css

Although @Jevuska did solve my issue, I have found a much easier solution to adding dynamic CSS from my theme options page. Here we go! Add this to functions.php add_action(‘wp_head’, ‘my_custom_css’); function my_custom_css(){ require_once( get_template_directory() . ‘/css/theme-styles.php’ ); } Now you can treat theme-styles.php as a normal CSS stylesheet <style type=”text/css”> a { color: <?php … Read more

Get Custom URL For Custom Taxonomy

Sorry to come to the party late. Here is my solution <?php //Retrieve the terms in productcategory taxonomy with posts (not empty) $terms = get_terms( array ( ‘taxonomy’ => ‘productcategory’, ‘hide_empty’ => false, ‘parent’ => 0, ‘orderby’ => ‘description’, ‘order’ => ‘ASC’ )); //loop through each term to get its attributes foreach ($terms as $term) … Read more

Is there a way to get 3+ dimensional array from a single MySql command

The direct answer to the question “Is there a way to get 3+ dimensional array from a single MySql command” would be yes, sort of – WordPress routinely stores and retrieves multidimensional data from MySQL rows by serialize()ing and unserialize()ing structured data to/from a string format, so it’s certainly possible using WordPress’s database interaction mechanisms. … Read more

Count the number of times the search form template gets included on a page

Just few simple ideas: A) Here’s one suggestion using the get_search_form filter with a static variable to handle the instance counting: add_filter( ‘get_search_form’, function( $form ) { static $instance = 0; $instance++; // Setup your form here with the $instance variable as needed: $form = ‘<form>…</form>’; return $form; } ); B) Another workaround would be … Read more

Upload Image in a WordPress page using PHP

Implementing your own upload form like this can be a major security vulnerability, you might want to instead use a library/script where such potential issues are already dealt with properly. Here is one I remember using successfully on a project for a similar purpose (user uploaded video)… though it may be more than what you … Read more

Store and Work with huge array in WP [closed]

In a nutshell your needs are completely unsupported by WP API. Taxonomies in WP are a grouping mechanism. Their primary purpose is to query set of objects, belonging to a group (term) or groups. There is no reverse operation to provide a set of objects and inquire which groups (terms) it belongs to. On top … Read more