Articles of custom field

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.

Solve product properties with custom taxonomies?

I need to add about 50 properties to a product, such as heigh, width, location etc. I created custom taxonomies for every property and ran into serious problems. First of all, the UI is a mess! Every taxonomy uses to much space. Some of the propertys should be presented to the user with radio buttons, […]

Make URL in custom field hyper link

In my WordPress site I have created a custom field for author website link. but I don’t know how to make it hyperlink, so people can click on it to surf that website. at this moment it only shows raw text. like: “www.example.com” my code is: <?php echo get_post_meta($post->ID, ‘Author Website’, true); ?>

Filtering a WP_Query meta_query by numeric values isn't working

That was a very dense title. I have a custom post type “event” which has a Date/Time picker field “event_date” thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX timestamp to the database. I’m trying to use WP_Query to get all events that are today or in the future. This is […]