Articles of custom field

2 orderby in wp_query with 2 custom fields

I’m triyng to display hotels (taxonomy which i have created) by two ‘orderby’ with wp_query but i’m not success. Results looks likes: Hotel 1 : 2 persons 5 stars Hotel 2 : 2 persons 4 stars Hotel 3 : 2 persons 3 stars Hotel 4 : 3 persons 5 stars Hotel 5 : 5 persons […]

How to remove duplicate Custom Fields?

I have migrated my blog from blogspot to WordPress. Then I have noticed many of the posts contain duplicate custom fields. Like blogger_author, blogger_permalink, blogger_blog are duplicated upto 5 times. How can I remove the duplicate Custom Fields?

Get a custom field of all posts on current blog page

I am trying to get a custom field value from all posts listed on current blog paginated page. Not sure if it’s clear, let me explain it more. On blog index page (or on second page of pagination) I have 10 posts. And each post have a value for custom field my-field. So I want […]

Saving custom profile fields

I’m adding a custom profile field to users of a specific role, like this : function add_custom_profile_fields( $fields ) { // get current user ID $user = new WP_User( $_GET[‘user_id’] ); // get current user role if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ) { // […]

Preserving line breaks when saving and displaying custom fields data

I’m collecting data via a form plugin and saving that data in form of a post with several custom fields. I then display the content of the post and the custom fields on my post template using… if( get_post_meta( $post->ID, ‘_aboutus’, true ) ) : echo ‘<div class=”companyaboutus”>’ . get_post_meta($post->ID, ‘_aboutus’, true) . ‘</div>’; endif; […]

Is it acceptable to build functionality into a theme built for a client?

I know it’s now the common wisdom to not build functionality into themes, as advised by WordPress, Envato, and others. This includes the likes of content types, taxonomies, sliders, shortcodes etc, to make themes as flexible as possible when used for different applications. I know I don’t like downloading themes which have more functionality built-in […]

Add field to 'Add User' admin page

How can I add an input field to the admin section Users -> Add New? I want to add a field for a phone number, but don’t want a plugin to do that.

Using more than one meta_key in pre_posts_query

I am already filtering some custom posts depending on a querystring in pre_get_posts: if( $query->is_main_query() ) { if( is_post_type_archive( ‘events’ ) ) { if ($_GET[‘status’]) { $retrieved_status = $_GET[‘status’]; $query->set(‘meta_key’, ‘event_status’); $query->set(‘meta_value’, $retrieved_status); } } } I would then also like to sort by a different custom field, but I can’t use something like below […]

meta query not showing any results?

I’m trying to show result for a custom field that is not empty on a custom post type but getting no results? <?php if (have_posts()) : $args = array( ‘post_type’ => ‘programmes’, ‘meta_query’ => array( ‘key’ => ‘linktovideocatchup’, ‘value’ => ”, ‘compare’ => ‘NOT LIKE’), //’caller_get_posts’ => 1, ); ?> <?php query_posts( $args ); ?> […]

How to display all custom fields associated with a post type?

What is the best way to display/dump all custom fields associated with a post? It doesn’t have to be pretty, I just need to verify what is being saved in what field array for debugging.