wp_set_object_terms() not adding new term to custom post and custom taxonomy

Use the fourth parameter in wp_set_object_terms() and pass true. wp_set_object_terms( $pid, $name, ‘name’, true); wp_set_object_terms( $pid, $email, ’email’, true); wp_set_object_terms( $pid, $birthdate, ‘dob’, true); Though I do find it weird to use taxonomies for name, email and birthdate. I’d recommend to use metadata for this. See: https://codex.wordpress.org/Function_Reference/update_post_meta Taxonomies are meant for categories and tags like … Read more

How can i change the output of posts_nav_link();

posts_nav_link() just outputs get_previous_posts_link() and get_next_posts_link() with a separator between them. The helpful thing is does is handle the visibility of the separator depending on whether both pages exist. Since you always want to show something on either side, you don’t need it. What you can do is output the next and previous links manually, … Read more

WordPress Genesis custom taxonomy archive shows 3 repeats of each post

You are using a nested loop in your code. You should only use the foreach loop, and pass the post ID to get_field(). Here’s an example: $terms = get_terms( [ ‘taxonomy’ => ‘collection_categories’, ‘orderby’ => ‘name’, ‘order’ => ‘DESC’ ] ); // Rest of the code here foreach ( $posts as $post ) { //* … Read more

Custom Post Type using single.php is looking for a template that doesn’t exist

Without seeing more code, on the surface it looks like a typo somewhere because the {$posttype} would be tall_homes. You could try putting an override function in your theme’s functions.php file though that should get around this: function tall_homes_override( $template ) { global $wp_query; $post_type = get_query_var( ‘post_type’ ); if ( $wp_query->is_single && $post_type == … Read more

Custom post type not showing in admin menu

Finally I found it. I was sure WP_DEBUG in wp-config.php was set to true, but it wasn’t. So after changing this I got a message saying that 20 characters is maximum for a post type name. [Sun Apr 08 18:29:44.083267 2018] [:error] [pid 5901] [client 127.0.0.1:45860] PHP Notice: register_post_type wurde fehlerhaft aufgerufen. Der Name eines … Read more

Templates and meta

get_post_meta is your friend. get_post_meta( int $post_id, string $key = ”, bool $single = false ) Retrieve post meta field for a post. Note that custom fields are named post meta internally. e.g. $key_1_value = get_post_meta( get_the_ID(), ‘key_1’, true ); // Check if the custom field has a value. if ( ! empty( $key_1_value ) … Read more