Anpress point to WP Categories?

6.57K viewsGeneral
0

I am developing a site and it revolves around Anspress. I have a BNWF plugin that utilizes WP Categories to fire off notifications of a new post.
The issue I’ve ran across is that with Anspress categories add on, it creates an entire new category type. I added the category add on in order to have the category drop down appear on the submit a question form.
I was wondering if it is possible to point the Anspress Categories to the default WP Categories (that all the notifications are tied to) so that when a new question is submitted the notifications are fired off for that category. I have something like 75 different categories there.

Answered question
0

Is there an easier way to accomplish?

Answered question
0

Add this to your theme functions.php

add_filter( 'ap_addons', function( $addons ){
    $addons['my-category.php'] = array(
        'name'        => __( 'My Categories', 'anspress-pro' ),
        'description' => __( 'Add question_label taxonomy for labelling questions.', 'anspress-pro' ),
        'path'        => ANSPRESS_ADDONS_DIR . 'my-categories/category.php',
        'pro'         => true,
    );
     return $addons;
} );


Make sure to replace file name in this code.

Posted new comment

I have my new categories addon in here:
/addons/wpcategories/

I’ve made the code change to the functions file and changing the line:
‘path’ => ANSPRESS_ADDONS_DIR . ‘wpcategories/categories.php’,

This has no change.

I am assuming my gist was alright, and all the current changes you’ve had me to up to this point are still in affect.

I am really trying to understand the file, and I get a little of what is going on, but the addon within a plugin is alluding me.

0

Okay, my /category/ folder contains 2 PHP files:
widget.php, categories.php
I search for “question_category” in both those files. I’m assuming I don’t have to change everything from question_category to category. So I changed everything that was looking like it was using that string: ‘question_categories’ in any method or url string (get_terms(), etc)
I added the hook on line 76 of categories.php.
I can’t seem to get the addon to show up to enable in in anspress.
I did change this in the Widget file (thought it might need to be unique) no change.

parent::__construct(
   'AnsPress_WP_Category_Widget',
   '(AnsPress) WP Categories',
   array( 'description', __( 'Display WP categories', 'anspress-question-answer' ) )
  );

Posted new comment

Share your categories.php with me. Please us gist.github.com

Here is my current work in progress categories.php along with the original for reference.
https://gist.github.com/WadeTheFade/1dbaa65775548e0ccefc2e8cb354528a

Any update?

0

For this you need to edit whole category addon. Simply copy category addon directory and rename it. Then open PHP file and find for question_category taxonomy in all file and replace with category.
Comment line 43 in category.php. and add this hook:

add_filter( 'ap_question_cpt_args', function( $args ){
    $args['taxonomies'] = array( 'category' );
    return $args;
});


And now disable default category addon and enable yours.

Posted new comment

Following the steps mentioned here. Renamed the “categories” folder and added it under the Anspress Addons folder. But the new folder (addon) is not showing up as an available Addon in WordPress Admin dashboard – AnsPress Add-ons page. Am I missing something here? Thanks for your help in advance.