How to display custom field on homepage

Try this: if ( ! function_exists( ‘customField’ ) ) : function customField($name, $id=false, $single=false){ global $post_type, $post; $name=trim($name); $prefix=”; // only if you need this $data=NULL; if($id!==false && !empty($id) && $id > 0) $getMeta=get_post_meta((int)$id, $prefix.$name, $single); else if(isset($post->ID) && $post->ID > 0) $getMeta=get_post_meta($post->ID,$prefix.$name, $single); else if(‘page’ == get_option( ‘show_on_front’ )) $getMeta=get_post_meta(get_option( ‘page_for_posts’ ),$prefix.$name, $single); else … Read more

User Relationship

if I were you, I would use the wp_usermeta table. it is possible to add information to this table easily: add_user_meta(NEW_USER_ID, “PARENT_USER_ID”,USER_ID,true); USER_ID: the Id of top level user, (In your case id of user A) “PARENT_USER_ID”: some key that you could search and find result based on NEW_USER_ID: The Id of sub_user true: To … Read more

Display custom post types with custom date field value (before today) & order by custom date field

I prefer to use WP_Query (for more info read “When should you use WP_Query vs query_posts() vs get_posts()?“), try this way: $args = array( ‘post_type’ => ‘soiree’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date_de_concert’, // you don’t need ‘meta_key’ => ‘date_de_concert’ when using meta_query //’meta_key’ => ‘date_de_concert’, ‘order’ => ‘DESC’, ‘meta_query’ => array( … Read more

Meta-value query

The string you are outputting using print_r() is what is known as a serialized string. When WordPress stores an array of values in 1 custom field, it compresses the array into this string using a function called serialize() What you want to do is to unserialize the string, and then you can access each “associated … Read more

how to create a proper query for getting a list of users with taxonomy related meta key

Objective I want to list sp_provider (hospital,clinics,doctors) whose sub_category is suppose ‘neurology’ rephrasing the words: I want to list users with sp provider category(meta value) such as “hospital” and the user have a sub category(meta value) “neurology” sp_provider is a meta value in user profile (sp-provider maybe a post-type or something for user management screen … Read more

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