0

I have implemented Full Calendar via json with my Wordpress custom post types.

All is fine except I want to add the taxonomy term of the event / post to the 'className' of the event object but cant seem to get it working, can someone please take a gander at my implementation see where I am going wrong?

I cant seem to get my pasted code formatting legibly as such I have added a link to a pastebin, apologies, can be see here

get_single_term relates to a custom function to output the first term of the taxonomy as follows ....

function get_single_term($post_id, $taxonomy) {
$terms = wp_get_object_terms($post_id, $taxonomy);
if(!is_wp_error($terms))
{
    echo $terms[0]->name;   
} }

Thanks for any advice

0

You are using get_single_term in a way that would require it to return a value...

$term = get_single_term($post->ID, 'course_locations');

... but you have written it in such a way that it echos a value. You should have...

function get_single_term($post_id, $taxonomy) {
  $terms = wp_get_object_terms($post_id, $taxonomy);
  if(!is_wp_error($terms))
  {
    return $terms[0]->name;   
  } 
}

I noticed a couple of other things not directly related to the question but worth mentioning.

  1. You really should be using the AJAX API. includeing wp-load.php like that is a kind of hack, in my opinion, that is no longer necessary. It is also prone to error. Imagine if someone were to move one or more of the content directories.
  2. You should really learn to indent your code. You are going to run into all kinds of headaches trying to debug "flat" code like that.
  • good spot, working now – John May 12 '13 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.