Convert custom fields to post categories

It’s a good question. There is many ways to apply a little script but the simplest way to do this take a few lines. A note about the following code: Most parameters might be added to the query like meta_query, category. wp_create_category(), will create a category once. wp_set_post_terms(), only work with native post types, will … Read more

With WordPress Importer, why can’t I import post meta containing a multi-dimensional array, in which value(s) of that array contain line breaks?

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they’ll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they’ll only be counted as 1 character and they’ll corrupt the string. I tested this hypothesis and sure enough I … Read more

Adding meta values to permalink

Was able to get this working. Thought I would write down what we did in the hopes that it will help someone in the future (or someone can give me feedback on how to better improve it!) Registered Custom Rewrite Rules add_action(‘init’, ‘pub_rewrite_rules’); function pub_rewrite_rules() { global $wp_rewrite; $wp_rewrite->add_rewrite_tag( ‘%pubyear%’, ‘([0-9]{4})’, ‘pubyear=”); $wp_rewrite->add_rewrite_tag( “%pubmonth%’, ‘([0-9]{2})’, … Read more

echo value from ‘select’ field type into page template using cmb2?

For starters, I recommend you use the API for register metaboxes and fields which can be seen here: https://github.com/WebDevStudios/CMB2/wiki/Basic-Usage#create-a-metabox. To echo the select option’s label, you would do something like this: add_action( ‘cmb2_admin_init’, ‘custom_metabox’ ); function custom_metabox() { $cmb = new_cmb2_box( array( ‘id’ => REALIA_PROPERTY_PREFIX . ‘ficha_tecnica’, ‘title’ => ‘Ficha Técnica’, ‘object_types’ => array( ‘property’ … Read more

How can i force Display names to be the same as Usernames?

You can use the wp_pre_insert_user_data filter. function wpse_filter_user_data( $data, $update, $id) { if( isset( $data[ ‘user_login’ ] ) ) { $data[ ‘display_name’ ] = $data[ ‘user_login’ ]; return $data; } $user = get_user_by( ’email’, $data[ ‘user_email’ ] ); $data[ ‘display_name’ ] = $user->user_login; return $data; } add_filter( ‘wp_pre_insert_user_data’, ‘wpse_filter_user_data’, 10, 3 ); You’ll probably want … Read more

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