Get Meta from Custom Field of Image URL

I can already tell that you’re using ACF – if you don’t want to change the return settings for the field, you can bypass ACF and just pull the image ID directly from post meta: $image_url = get_field( ‘my_field_name’ ); $image_id = get_post_meta( $post->ID, ‘my_field_name’, true ); $image_meta = wp_get_attachment_metadata( $image_id );

Custom User Profile Fields

You’re going to definitely want to do this with a plugin. Modifying WordPress Core files is an extremely bad idea as others have pointed out because every update will wipe them out and future versions may change the location/function of what you’re editing. You can get away by adding it to the theme’s functions.php file … Read more

woocommerce product custom field

You should ad the custom field to product API response, try this (untested) add_filter( ‘woocommerce_rest_prepare_product’, ‘custom_products_api_data’, 90, 2 ); function custom_products_api_data( $response, $post ) { // retrieve a custom field and add it to API response $response->data[‘purchasing_cost’] = get_post_meta( $post->ID, ‘purchasing_cost’, true ); return $response; }

Redirect users based on custom field

According to your functions, if you want to redirect users when they are visiting the website’s homepage. You could implement the is_front_page() function to detect and only redirects if they are on the frontpage. function user_homepage() { if ( is_user_logged_in() ) { $args = array( ‘field’ => 25, ); $user_homepage = bp_profile_field_data( $args ); if … Read more

How to update custom user meta field in wp?

You are using the wrong meta key: update_user_meta( $user_id, ‘Save Posts’, $_POST[‘save_post_external’] ); update_user_meta( $user_id, ‘Save Posts’, $_POST[‘save_post_internal’] ); And that should be: update_user_meta( $user_id, ‘save_post_external’, $_POST[‘save_post_external’] ); update_user_meta( $user_id, ‘save_post_internal’, $_POST[‘save_post_internal’] );

meta_query for a string inside a meta field containing a comma-separated list

Is there a smart way to meta_query so it matches just “IS, but not “TS-IS”? The WordPress meta query class (WP_Meta_Query), which among others, is used with the posts (WP_Query) and users (WP_User_Query) query classes, supports REGEXP (since WordPress 3.7) as the compare value, so you could use that with a RegEx (regular expresion) pattern … Read more

Count how many posts have a custom field set

You could run a custom query to count the amount of posts with a given key using $wpdb or more specifically using get_var(). If i assume you want to count published posts with a given key, then something like the folowing should do it..(though this is just an example). function get_meta_count( $key = ”, $type=”post”, … Read more

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