WordPress.org

Forums

WP-dTree
Custom Post Type + Taxonomy (11 posts)

  1. jharder
    Member
    Posted 4 years ago #

    Just installed WP-dTree and it works fine with my site's default categories. My goal is to use it to display a custom taxonomy categories, populated with posts of a custom post type. This does not work.

    There does not seem to be any way to select post type/taxonomy in the widget settings.

    Also tried adding the template tag like so...
    wpdt_list_categories('post_type=myposttype&taxonomy=mytaxonomy');
    This will display the custom taxonomy category names, but does not build the links properly, does not display the post count, and does not display post names/links.

    Am I missing something? Does this plugin not support custom post-types/taxonomy?

    Thanks for any advice.

  2. jharder
    Member
    Posted 4 years ago #

    Correction: Post count is working, but I cannot display post names (even with listposts=1 in my args) and the category names are not linking properly

  3. ulfben
    Member
    Plugin Author

    Posted 4 years ago #

    WP-dTree does not support custom post-types/taxonomy. I don't even know what they are.

    You can try and convince that it's a worthile feature though. I recommend you start by linking me to some proper documentation explaining what they are, how they are used and what for.

    And also books. Books are very persuasive. :)

  4. jharder
    Member
    Posted 4 years ago #

    Codex page on custom taxonomy (aka custom categories) http://codex.wordpress.org/Taxonomies#Custom_Taxonomies

    Codex page on post types (pretty much the main attraction for WP 3.0 imo)
    http://codex.wordpress.org/Post_Types

    wp_list_categories has a taxonomy arg (ie taxonomy=my_taxonomy) which will return only categories from that specified category group. Works like a charm. Using the wpdt_list_categories with the same arg returns the correctly filtered category names, but the links are all written as href=mysite.com/category instead of href=mysite.com/custom-category-name

  5. ulfben
    Member
    Plugin Author

    Posted 4 years ago #

    Interesting stuff for sure. I'll probably take a crack at it soonish.

    As for the link-errors, try opening wp-dtree-cat.php and change the MySQL-query at line 47:
    AND {$wpdb->term_taxonomy}.taxonomy = 'category'

    To:
    AND {$wpdb->term_taxonomy}.taxonomy = $taxanomy

    And of course, make sure you've set the correct rewrite-argument when calling register_taxonomy.

  6. ulfben
    Member
    Plugin Author

    Posted 4 years ago #

    Oh, and probably change all get_category_link($cat->term_id) to get_term_link($cat->term_id, $taxanomy) too.

  7. jharder
    Member
    Posted 4 years ago #

    Cool. Thanks ulfben. With your suggestion I should be able to work out the solution. I will post it here if I do.

  8. johnnymestizo
    Member
    Posted 4 years ago #

    +1

  9. jharder
    Member
    Posted 4 years ago #

    I tried the suggestions above, but no luck. The category URLs are still not correct. Maybe the problem is in how I am registering my taxonomy? Here's the code I'm using:

    function create_transitshare_taxonomies() {
    	register_taxonomy( 'transitshare-category', 'transitshare', array( 'hierarchical' => true, 'label' => 'transitSHARE Categories', 'rewrite' => array("slug" => "transitshare-category") ) );
    }

    That said - I think the bigger issue is getting posts from a custom post type. I tried changing the post_type from 'post' to 'name of my custom post type' in line 103 of wp-dtree-cat.php but no luck there either.

  10. ulfben
    Member
    Plugin Author

    Posted 4 years ago #

    Yeah, I suspect this will require a fair bit of re-wiring. WordPress internal functionality is always very close but not quite what I need (for categories especially) so there's a bunch of custom queries in there that'll need major revisions.

  11. jharder
    Member
    Posted 4 years ago #

    No kidding! I can either get categories with posts (but no category hierarchy) or hierarchical categories (but no categories).

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-dTree
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic