Skip Navigation

Open

Topic Tags: Compatibility

Overview of the issue

If you are using BetterDocs Pro plugin, you will notice that the knowledgebase slug is not properly translated on the category page. When switching between languages, the slug for the Knowledgebase terms do not reflect the change in language, leading to inconsistent URLs on the category page.

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open …/wp-content/plugins/betterdocs-pro/includes/Traits/MKB.php file.
  • Look for line 21.
  • Change:
    public function kb_terms( $term, $taxonomy ) {
        $current_term = get_term_by( 'slug', $term->slug, $taxonomy, OBJECT );
        $_term_attr   = get_term_meta( $current_term->term_id, 'doc_category_knowledge_base', true );
    
        if ( ! empty( $_term_attr ) ) {
            $_term_attr = array_values( array_filter($_term_attr, function( $item ){
                return ! empty( $item );
            }) );
        }
    
        return $_term_attr;
    }
  • For:
    public function kb_terms( $term, $taxonomy ) {
        $current_term = get_term_by( 'slug', $term->slug, $taxonomy, OBJECT );
        $_term_attr   = get_term_meta( $current_term->term_id, 'doc_category_knowledge_base', true );
        
        // WPML Workaround for compsupp-6478
        if ( class_exists('Sitepress') ) {
            $_term_attr   = get_term_meta( $term->term_id, 'doc_category_knowledge_base', true );
        }
        
        if ( ! empty( $_term_attr ) ) {
            $_term_attr = array_values( array_filter($_term_attr, function( $item ){
                return ! empty( $item );
            }) );
        }
    
        return $_term_attr;
    }
    

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>