Using more than one meta_key in pre_posts_query

Use WP_Query to select any post based on meta key and value. You can also sort posts Ex: $args = array( ‘post_type’ => ‘events’, ‘orderby’ => ‘meta_value_num’, //probably you will need this because the value is date ‘meta_key’ => ‘event_date’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event_status’, ‘value’ => $retrieved_status, ‘compare’ => … Read more

Saving custom profile fields

Ok, I was doing it wrong, here’s a working solution, based on Justin Tadlock’s tutorial. <?php /* Add custom profile fields (call in theme : echo $curauth->fieldname;) */ add_action( ‘show_user_profile’, ‘my_show_extra_profile_fields’ ); add_action( ‘edit_user_profile’, ‘my_show_extra_profile_fields’ ); function my_show_extra_profile_fields( $user ) { ?> <?php if(user_can($user->ID, “paying_member”)) : ?> <h3>Extra profile information</h3> <table class=”form-table”> <tr> <th><label for=”paypal_account”>Paypal</label></th> … Read more

Force hide custom field metaboxes

http://codex.wordpress.org/Function_Reference/remove_meta_box function remove_custom_meta_form() { remove_meta_box( ‘postcustom’, ‘post’, ‘normal’ ); remove_meta_box( ‘postcustom’, ‘page’, ‘normal’ ); } add_action( ‘admin_menu’ , ‘remove_custom_meta_form’ ); HTH

meta query not showing any results?

you’re missing an array within the meta_query element: $args = array( ‘post_type’ => ‘programmes’, ‘meta_query’ => array( array( ‘key’ => ‘linktovideocatchup’, ‘value’ => ”, ‘compare’ => ‘NOT LIKE’ ) ) ); (this is required to allow for querying of multiple meta fields.) you also had an extraneous comma after the meta_query array element which can … Read more

Make URL in custom field hyper link

Use this. get_post_meta($post->ID, ‘custom-field-name’, true); Where custom-field-name is the name of the custom field. You will have to add your custom field name in place of custom-field-name. Also to open link in new browser window/tab add target=”_blank”. Always use esc_url() for URLs and esc_html() when you want to display a value without working HTML. $value … Read more

Is it bad to use a lot of Custom Meta Fields?

Custom Fields are normally fetched in a single query to the database, so fetching 1 or 10 isn’t going to make a lot of difference in performance of your WordPress site. The problem is with doing complex meta queries on existing custom fields; that’s when your site would see a performance hit. Obvious, isn’t it? … Read more

Title and post URL based on custom fields?

I think a good way to do what you want is hook the wp_insert_post_data filter. Here you can change the title and slug of the post before it is saved to database: add_filter( ‘wp_insert_post_data’, ‘wpse_update_post_title_and_slug’ ); function wpse_update_post_title_and_slug( $data ) { //You can make some checks here before modify the post data. //For example, limit … Read more

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