Problem with serialized arrays in custom meta

See my comment on your question above. I just realized that if you’re ending up with those special characters in the database, most likely you’re not sanitizing the data before saving it into the database. Try running htmlentities() over all the values that you’re saving into that serialized array, and see if you end up … Read more

Using Custom Fields in Custom Post Type URL

I managed to fix this. Basically I changed the permastruct to this: $wp_rewrite->add_permastruct(‘showroom’, ‘location/%state%/%city%/%showroom%’, false); I then grabbed state & city as two separate variables, replacing it in the permalink structure using these lines: $permalink = str_replace(‘%state%’, $state, $permalink); $permalink = str_replace(‘%city%’, $city, $permalink); With $state & $city grabbed using get_post_meta from the post.

WP_Query orderby custom field then post_date in one query

Multiple meta_query arguments with OR You may use the ‘relation’ => ‘OR’ argument in meta_query with two sets of field_order arguments: one with meta_value >= ‘0’ and the other one with NOT EXISTS to generate the main query. ‘meta_query’ => array( ‘relation’ => ‘OR’, field_order’ => array( ‘key’ => ‘field_order’, ‘value’ => ‘0’, ‘compare’ => … Read more

How to access custom order item meta data from a meta key in WooCommerce?

There is at least 2 ways to get custom order item meta data from a defined meta key: 1) Since WooCommerce 3 – Using WC_Data method get_meta() 2) The older way – Using wc_get_order_item_meta() WooCommerce function So your hooked function bs_order_lead_time_data() code will be: add_action( ‘woocommerce_my_account_my_orders_column_order-lead-time’, ‘bs_order_lead_time_data’ ); function bs_order_lead_time_data( $order ) { foreach ( … Read more

Custom search: by post data and post metadata?

The built-in WP search looks only a Posts’/Pages’ Title and Content, not thru other elements like Custom Fields and the content of Shortcodes. There’s a number of plugs that will search Custom Fields: http://wordpress.org/extend/plugins/wp-custom-fields-search/ http://wordpress.org/extend/plugins/search-everything/ http://wordpress.org/extend/plugins/relevanssi/ There also a filter apply_filters_ref_array() that “allows plugins to contextually add/remove/modify the search section of the database query.” FYI, … Read more

How to order adjacent posts (prev / next) by custom field value?

You can filter SQL to change to your condition in get_adjacent_post() ( source ) : $sort = apply_filters( “get_{$adjacent}_post_sort”, “ORDER BY p.post_date $order LIMIT 1” ); Or filter link altogether in adjacent_post_link() ( source ) : echo apply_filters( “{$adjacent}_post_link”, $format, $link ); PS $adjacent can be next or previous.

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