Articles of custom field

Displaying Meta Box Image

I have some problems displaying info from my custom meta box in my custom post type single. I’m using Reusable Custom WordPress Meta Boxes by Tammy Hart. I’m able to display the textfields using this: <?php echo get_post_meta($post->ID, $prefix.’hjemmeside’, true); ?> But I can’t get the image to display, instead DEBUG is telling me that […]

handling csv data with a custom post type

I have a custom post type which represents a ‘race’ and there are meta fields for ‘distance’ (5km,10Mile) and ‘type’ (track,road,crosscountry). We get the race results as a csv file which contains the positions and times etc of the runners, each runner is linked to a wordpress user. The intention is to process the csv […]

Admin Area Custom Type Search By Meta Fields Without Title & Content

I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code: function custom_search_query( $query ) { if ( is_admin() && is_main_query() && $query->is_search ) { $query->set(‘meta_query’, array( “relation” […]

List the number of posts for each custom taxonomy and specific custom field value

I would like to list my posts by a specific taxonomy. At the same time, for each taxonomy, I woud like to count the number of posts with a specific custom field value. So the list would look like this: for each: custom taxonomy name / count of posts / count of posts in this […]

How do I query for a post by custom field?

I have a custom field called “song-id” and I’d like to lookup a post by a song-id value. Can someone give me the code snippet for it? (bonus: also looking for a code to use the permalink in the post to redirect to that page)

Title and post URL based on custom fields?

I have custom fields in my custom post type. They should serve as a title and post slug for URL. Basically, whenever I change the content of the custom fields, the title field should react accordingly. E.g. if the field NAME contains ‘John’ and the SURNAME ‘Smith’, the title should transform to ‘John Smith’. The […]

Conditional to modify query results

I’ll admit, I’m not a PHP expert, nor am I familiar with all of the WordPress functions and hooks. I’ve been stuck on an issue, searching for help without much success, and I was hoping that someone could help point me in the right direction. I have a form. The user selects a specialty, location, […]

Filter a custom field based on selection of another custom field (ACF)

I have 3 custom post types with Advanced Custom Fields: Student Class Homework Assignment Homework has a custom field that is a ‘relationship’ with Class. This is because specific pieces of homework are related to specific classes. A Student has a relationship field with Class because each student is part of a class. Now I […]

$wp_query meta_key naming issue

What I am attempting to do is sort posts by custom fields. I have a few custom fields that don’t query properly and I get the 404 page. The fields that don’t work I used hyphens in the naming convention, i.e. var-name. When I switch the hyphens to underscores it works, i.e. var_name. Am I […]

Extra filed under “About the user” user profile

I use the following to add Phone number,linked id etc Under the “Contact Info” in user profile. Now I have to add a filed under the “About the user”. How can i do that? function my_new_contactmethods( $contactmethods ) { $contactmethods[‘designation’] = ‘Designation’; $contactmethods[‘linked_in’] = ‘Linked In’; $contactmethods[‘phone’] = ‘Phone Number’; return $contactmethods; } add_filter(‘user_contactmethods’,’my_new_contactmethods’,10,1); UPDATE […]