• Hey Hector

    Love your plugin and all the hard work you do keeping up with support posts!

    I’m integrating it on a site where I want to show popular custom post types with links to other terms in the taxonomy. For example, I have a “recipe” custom post type, with a taxonomy of “recipetypes” containing terms like “Drinks” and “Meals”
    In the WPP listing I want to link to the term as well as display the title and thumbnail for a post.

    I know you haven’t implemented the ability to display term links yet, so I hacked your code a little to make it work for me, and just thought I’d let you know what I did in case it’s very wrong!

    I modified _get_post_cat($p, $instance)

    There were only a couple of tweaks – you use get_the_terms() instead of get_the_category when dealing with a taxonomy, and the term title is called “name” not “cat_name”

    So I added/changed this:

    // Try and get parent category
    $taxonomy=get_object_taxonomies(get_post($p->id));
    
    if($taxonomy[0]=='category'){
    	$cats = get_the_category($p->id);
    }else{
    	$cats = get_the_terms($p->id, $taxonomy[0]);
    }

    and this

    if($taxonomy[0]=='category'){
    	$category_name = $post_cat->cat_name;
    }else{
    	$category_name = $post_cat->name;
    }

    Which is probably awful code! But it works for me at the moment ??

    Cheers

    Lucas

    https://www.ads-software.com/plugins/wordpress-popular-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Lucas!

    Thanks for sharing the code!

    I’ve already implemented taxonomy support on Recently (my new plugin, released a few days ago) and I’m planning to port over the functionality to WPP ?? What I did on Recently is similar to your code, so it’s not that bad ??

    Thread Starter pr0fess0r

    (@pr0fess0r)

    Oh awesome ?? Thanks Hector ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying Taxonomy Terms not categories’ is closed to new replies.