New answers tagged

1

From your explanation above I understood that you want to show custom taxonomy you have registered for that post type. the_category(); fetches the default category that comes with the default post. For rendering custom taxonomy you need to add something like this: $terms = get_the_terms( $post->ID , 'your custom taxonomy slug' ); foreach ( $terms as $...


1

If you want to get custom taxonomy comma separated listing than we can go with WordPress inbuilt function get_the_term_list() get_the_term_list( $id, $taxonomy, $before, $sep, $after ) $id : Post ID $taxonomy : Name of taxonomy $before : Leading text $sep : String to separate tags $after : Trailing text for example, <?php echo ...


-2

You should use the get_the_category function. So for example, I modified your code to show only the first category, keep in mind you get an array and you could also get the link by using get_category_link, check the comments on the first link to have more examples. <?php $homePageNews = new WP_Query(array( 'posts_per_page' => 3, '...


1

Instead of echoing right away, save the category names into an array, and then you can implode the array, which means output it with whatever separators between items you wish: <?php if(get_the_terms($post->ID, 'kernal_category', true)) { // Create an empty array $categories = []; $kernal_category = get_the_terms($post->ID, '...


0

First, get all term slugs from the custom example taxonomy space by current post ID. $space_terms = wp_get_post_terms( $post->ID, 'space' ); if( $space_terms ) { $space_terms = array(); foreach( $space_terms as $term ) { $space_terms[] = $term->slug; } } You should specify the logical relationship between each inner taxonomy array when there ...


0

You need to create a NEW pod that is a Category type, then simply associate it with your CPT pod.


0

I can reproduce this as well. Adding show_in_rest in register_taxonomy function, as suggested by many, would normally be proper answer, but not full answer in your case. This is because rest endpoint types is already in use by Wordpress itself. https://example.com/wp-json/wp/v2/types will return registered post types and therefore Gutenberg does not ...


1

On your code, the function wp_get_post_terms() return an array of WP_Term objects, so you can't access directly to an object property without specifying an index for the array like : $terms[0]->slug Otherwise, you should iterate through the whole array of terms and retrieve the slug into an another array, like : $terms = wp_get_post_terms( $post_id, ...


0

You can use post__not_in with the get_the_ID of the post in this case your code should be like this : $args = array( 'post_type' => 'custom_post_type', 'tax_query' => array( array( 'taxonomy' => '...


0

I updated your code there is 2-3 mistake in js file datatype and function file query parameter. Below I paste an updated code, please check and let me know incase of any doubts. Your album-page.php <?php $args = array( 'post_type' => 'albums',//Custom Post type name 'posts_per_page' => 10, ); $query = new WP_Query($args); $tax = '...


0

This is an idea But I did it thinking of ordering a listing on the front end You need to change the table "{prefix}term_taxonomy", creating the "term_order" field. See the function O_term_update_db(): In your function.php <?php function O_term_update_db(){ global $wpdb; global $term_db_version; $term_db_version = "1"; $...


1

You might have already figured this out, but here's an example how to get custom taxonomy terms for a post and create a list of links for the found terms. // used in your custom post type template, e.g. single-movies.php $genres = get_the_terms( get_the_ID(), 'genres' ); // current post has genre terms attached to it if ( $genres && ! is_wp_error( $...


0

At the beginning I will indicate that the expected structure conflicts with the default for custom post type produce posts. The solution to the problem requires changing the links created for the custom categories and appropriate parsing of new links to display the right posts. Use the pre_term_link filter to change links. One of the parameters passed ...


0

Try to rewrite the taxonomy url in the .htaccess RewriteRule ^produce_category(.*)$ /$1 [L] (Not tested)


Top 50 recent answers are included