MARKETPRESS – How to use my custom taxonomies with or instead

Hello.

I am having a little trouble with a couple things with the Marketpress plugin.

I am working on a site that currently has a registered custom taxonomy for categories and would like to know how can I use these categories with the product post type?

Also I have an additional custom taxonomy for tags which is used for states. I would like to know how can I use this as well as with marketpress’s default tags?

  • aecnu
    • WP Unicorn

    Greetings paul_jones,

    Welcome to WPMU DEV!

    Thank you for the great questions.

    I am working on a site that currently has a registered custom taxonomy for categories and would like to know how can I use these categories with the product post type?

    Also I have an additional custom taxonomy for tags which is used for states. I would like to know how can I use this as well as with marketpress’s default tags?

    I am sorry to report that both of these questions are beyond the scope of the support we provide here since they are not out of the box functions or related topics – though we do try to help if we know the answer or can offer any guidance.

    However, in an effort to help I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • paul_jones
    • Flash Drive

    Hi, thanks for the response.

    I understand what you are saying but I would like to remove the product_category and replace with my custom taxonomy. I figured if anyone will know how to assist me it would be here. I tried editing the plugin files but it did not change anything.

    Any help to point me in the right direction will be appreciated.

    Thank you.

  • paul_jones
    • Flash Drive

    Hi, thanks for the response. However this only helps with removing the category, and I’ve already referred to the wordpress codex about adding the taxonomy but however it doesn’t seem to work this time.

    So I my quesyion is –

    Is there a way I can edit the plugin file to use my custom taxonomy?

  • Aaron
    • CTO

    You can attach any custom taxonomies you wish to the “product” post type, you don’t need to mod MarketPress code at all for that. This should show them in the product edit screens.

    However if you want to display them on the front end on product listings or pages you will need to code that functionality yourself. There are hooks you can use in MP so you don’t need to mod core.

  • paul_jones
    • Flash Drive

    Hi, thanks again for the help thus far. However I’ve tried everything I can think of to add the taxonomy and nothing seems to take effect. I’ve replaced product_category with my custom taxonomy name in marketpress files, and where the product post is registered in the plugin, I’ve added an array to use my taxonomies but still no effect. I’ve also tried using the recommended way of adding taxonomies register_taxonomy_for_object_type but that has no effect even though I’ve used it before successfully for my other post types. So since this seems to only give me this problem with this plugin, I would like to know from the developers what else can I do to try and use my custom taxonomies??

  • paul_jones
    • Flash Drive

    Do you mean the code I am using to add the taxonomy to the product post type? If so this is what I am trying to use as of now – `if(!function_exists('add_categories_to_cpt':wink:)

    {

    function add_categories_to_cpt()

    {

    add_action('init','add_categories_to_cpt':wink:;

    function add_categories_to_cpt(){

    register_taxonomy_for_object_type('videoscategory', 'product' );

    }

    }

    }

    `

    I've used the add_categories_to_cpt code on other post types and it has worked.

    I've managed to get the categories to show up on top as a dropdown filter, I've attached a screenshot.

  • paul_jones
    • Flash Drive

    Hi, thank you for your help, you helped me solve my problem.

    In case anyone else is interested this is how I was able to use my own custom taxonomies with MarketPress —

    1. First I had to unset the default taxonomies used by MP, I accomplished this by using some coding found at the link Aaron suggested.

    Should be able to override:

    http://stackoverflow.com/questions/4249694/how-do-i-remove-a-taxonomy-from-wordpress

    I placed this code into my themes function.php file –

    add_action( 'init', 'unregister_taxonomy');
    function unregister_taxonomy(){
    global $wp_taxonomies;
    $taxonomy = 'product_category';
    $taxonomy = 'product_tag';
    if ( taxonomy_exists( $taxonomy))
    unset( $wp_taxonomies[$taxonomy]);
    }

    2. Then I added my custom taxonomies by adding another code into the same file –

    add_action('init','add_categories_to_cpt');
    function add_categories_to_cpt(){
    register_taxonomy_for_object_type('YOUR-TAXONOMY-NAME', 'product' );
    register_taxonomy_for_object_type('YOUR-TAXONOMY-NAME', 'product' );
    }

    3. i received a error on the back end that didn’t allow the taxonomies to fully register, and caused an error where I was only seeing one product at a time when I know there were many more. This is the error it showed –

    Catchable fatal error: Object of class WP_Error could not be converted to string in /wp-content/plugins/marketpress/marketpress.php on line 1702

    So I had to go in and edit the plugin file to fix this. I edited the line stated in the error and a few others as well just to be safe. Wherever it said “product_category or product_tag” I replaced it with the names of my own custom category taxonomy and custom post tag taxonomy.

    After that everything worked, =)

    @aaron Thanks again for helping me figure it out.

  • aecnu
    • WP Unicorn

    Greetings paul_jones,

    Thank you for letting us know, we are happy if you are happy and also kudos for posting the coding above so others interested in dabbling into this have something to go on.

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.