Formatting of curly brackets array from WP database to get more readable output

This is a serialized value, so you should run it through maybe_unserialize() or just unserialize() before you edit it. When you work in plugins or themes, always use the API: update_option() and get_option() for example. These functions will un/serialize the values for you, so you don’t have to worry about the database. See also: Settings … Read more

How do I search an array stored in a custom-field using WP_Query?

Searching inside a serialized array is difficult and inefficient– ie. slow. The following pure SQL will do it: SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE ‘daysonair’ AND `meta_value` LIKE ‘%thursday%’ LIMIT 0 , 100 Something like this should get WP_Query to do something similar: $args = array( ‘post_type’ => ‘post’, ‘meta_query’ => array( array( ‘key’ … Read more

WordPress: How to use post_class() in an echo

The post_class() function just is a wrapper for get_post_class(). Keep in mind that the latter does not echo, but returns an Array so you have to do something like what post_class() does: $classes = join( ‘ ‘, get_post_class() ); Your code (could) would look like the following. I changed the if check as well to … Read more

Getting an array out of WPQuery

Your function returns $product->get_id();, instead of that, you should save those values into an array and at the end return that array. function ids(){ $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘product’, ‘meta_key’ => ‘wppl_is_dax’, ‘meta_value’ => ‘1’ ); // query $the_query = new WP_Query( $args ); $allIds = array(); if( $the_query->have_posts() ): while( … Read more

Autogenerate wordpress shortcodes using array?

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( “get_address” => “mg_admin_address”, “get_phone” => “mg_admin_phone”, “get_fax” => “mg_admin_fax”, “get_email” => “mg_admin_email”, “get_hrs_mon” => “mg_work_hrs_mon_frd”, “get_hrs_sat” => “mg_work_hrs_sat” ); $sc = new ShortCodeAutomat( $settings ); $sc->generate(); } add_action( ‘wp_loaded’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)