Skip to main content

The first line of the code in your question appears to be the problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should work for you:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

get_the_terms( int|WP_Post $post, string $taxonomy )get_the_terms( int|WP_Post $post, string $taxonomy ) https://developer.wordpress.org/reference/functions/get_the_terms/

The first line of the code in your question appears to be the problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should work for you:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

get_the_terms( int|WP_Post $post, string $taxonomy ) https://developer.wordpress.org/reference/functions/get_the_terms/

The first line of code in your question appears to be the problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should work for you:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

get_the_terms( int|WP_Post $post, string $taxonomy ) https://developer.wordpress.org/reference/functions/get_the_terms/

Updated word choices slightly; added details from WP Codex
Source Link
jdm2112
  • 3.7k
  • 1
  • 16
  • 23

The first line of the code in your question appears to be yourthe problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should be your fixwork for you:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

get_the_terms( int|WP_Post $post, string $taxonomy ) https://developer.wordpress.org/reference/functions/get_the_terms/

The first line of the code in your question appears to be your problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should be your fix:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

https://developer.wordpress.org/reference/functions/get_the_terms/

The first line of the code in your question appears to be the problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should work for you:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

get_the_terms( int|WP_Post $post, string $taxonomy ) https://developer.wordpress.org/reference/functions/get_the_terms/

Source Link
jdm2112
  • 3.7k
  • 1
  • 16
  • 23

The first line of the code in your question appears to be your problem.

The get_the_terms() function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.

Something like this should be your fix:

$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' ); 

https://developer.wordpress.org/reference/functions/get_the_terms/