• Resolved llucssll

    (@llucssll)


    Hi,

    Im using this plugin to order the taxonomies of my CPT, but when I enable the plugin the get_terms() function stops returning the taxonomies and returns an empty array instead. If I disable the plugin all goes back to normal and it prints all my taxonomies.

    This is the code I use:

    register_post_type(

    'products',

    array(

    'labels' => array(

    'name' => __('Productes', 'ssll'),

    'singular_name' => __('Producte', 'ssll')

    ),

    'public' => true,

    'has_archive' => false, // False Si no te archive page

    'menu_position' => 22,

    'menu_icon' => 'dashicons-image-filter',

    'supports' => array('title', 'editor', 'thumbnail'),

    'rewrite' => array('with_front' => false),

    )

    );

    register_taxonomy(

    'prod-categories', // The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).

    'products', // post type name in lowercase (not slug)

    array(

    'hierarchical' => true,

    'label' => 'Categoríes', // display name

    'query_var' => true,

    'show_admin_column' => true, // Display in backoffice's post_type table

    'rewrite' => array(

    'slug' => 'prod-category', // This controls the base slug that will display before each term

    'with_front' => false // Don't display the category base before

    )

    )

    );

    I then use the following code to print the taxonomy:

    $prod_tax = get_terms(array(‘taxonomy’ => ‘prod-categories’));

    var_dump($prod_tax);

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support beatrice12

    (@beatrice12)

    Hello @llucssll,

    Thanks for reaching out to us!

    Please try enabling debug mode to see if there are any errors. Open your wp-config.php file and add this:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);

    Then check the /wp-content/debug.log file after running get_terms(). If there’s an error, it might tell us what’s wrong.

    If that doesn’t help, try using the Health Check & Troubleshooting plugin. It has a troubleshooting mode, which lets you temporarily disable all plugins and switch to a default theme.

    Once you’re in Troubleshooting Mode, enable only Simple Custom Post Order and test get_terms(). If it works, start enabling your other plugins one by one to see which one is causing the issue.

    Let me know what you find!

    Warm regards,

    Beatrice.

    Thread Starter llucssll

    (@llucssll)

    Hi @beatrice12 ,

    I’ve tried to disable all plugins and it works fine. But as soon as I enable Simple Custom Post Order it stops working.

    Enabling WP_DEBUG shows this:

    WordPress database error: [Unknown column ‘t.term_order’ in ‘order clause’]
    SELECT t.term_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('prod-categories') ORDER BY t.term_order ASC

    Im pretty sure this is a plugin bug, as there’s nothing else on my end affecting the result.

    Thanks!

    Plugin Support beatrice12

    (@beatrice12)

    Hello @llucssll,

    Please go to website.com/wp-admin/options.php on your site and look for the option called scporder_install. Set it to 0 and save.

    When the plugin is first activated, it’s supposed to add a term_order column to the wp_terms table in the database. In your case, that step probably didn’t run properly.

    Let me know if you have questions!

    Warm regards,

    Beatrice.

    Plugin Support beatrice12

    (@beatrice12)

    Marking this support thread as resolved due to inactivity. If you have any other questions or need further help please open a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘get_terms() broken’ is closed to new replies.