Displaying a custom post types custom taxonomy value?
$albumGenres = get_the_terms( $post->ID, ‘discography_album_label’ ); foreach ( $albumGenres as $albumGenre ) { echo $albumGenre->name; // or whatever value }
$albumGenres = get_the_terms( $post->ID, ‘discography_album_label’ ); foreach ( $albumGenres as $albumGenre ) { echo $albumGenre->name; // or whatever value }
The main problem is that, in your $_POST loop, $value is an array, yet you apply htmlspecialchars to it, which will vomit and return back nothing. If you haven’t done so already, set WP_DEBUG to true in your wp-config.php – developing without it is simply not an option. Regardless, let’s fix that dirty $_POST loop: … Read more
I hope I understand this correctly. You can simply just add your post ID’s in an array and then use a foreach loop to loop through the ID’s and checking whether or not they have the term to assign or not, and if not, assign the term to the post $post_ids = [4522, 4524, 4526, … Read more
You can use usort to sort the object $children. The function to sort after you got the $children object can be like this: usort( $children, function($a, $b) { $ai = filter_var($a->name, FILTER_SANITIZE_NUMBER_INT); $bi = filter_var($b->name, FILTER_SANITIZE_NUMBER_INT); if ($ai == $bi) { return 0; } return ($ai < $bi) ? -1 : 1; });
Because get_the_terms will not always return an array; it will be false if the post has no terms, or a WP_Error if the taxonomy does not exist – always sanity check the result before looping: $terms_slugs = array(); $terms = get_the_terms( $post->id, ‘type’, /* Note: get_the_terms does not take a 3rd argument ==> */ array( … Read more
wp_dropdown_categories() does exactly that. Don’t let the name confuse you, it is not just meant for the built-in taxonomy category. Simply set the taxonomy parameter to the value of your custom taxonomy. Also work through the list of parameters and set as necessary. Just a small note on your code, avoid passing just term IDs … Read more
Posts are things Taxonomies and terms are types or classifications of things E.g. I could have a post type animal, with animals such as “Betsy”, “Rover”, and “Mittens”. I can then have a taxonomy called species, that contains terms such as cat, dog, budgie. I can then assign the “Mittens” post to the cat term … Read more
The characters <, >, &, ” and ‘ (less than, greater than, ampersand, double quote and single quote) are enconded in term names. & becomes &. This is done by passing the term object to sanitize_term() function which applies several filters. By default WordPress applies theses filters: sanitize_text_field(), wp_filter_kses() and _wp_specialchars() (see wp-includes/default-filters.php), this last … Read more
I found an answer that works well. Using two dropdowns in a ‘cascading’ style, with the code in the gist below, users would pick from a list of parent terms first, then a second dropdown appears with the list of children. The key is that both the parent and the child terms are ‘selected’. Just … Read more
On the top of my head there are two easy ways to go about this problem, first is to use the get_the_tags() function to manually loop the tags to easily insert the hashtags. $tags = get_the_tags(); if ( $tags ) { foreach ( $tags as $tag ) { ?> <a href=”https://wordpress.stackexchange.com/questions/225250/<?php echo get_tag_link( $tag->id ); … Read more