I need some help please. I have a WP theme (custom) its a old site deved years ago, im upgrading everything and Im getting some errors I need assistance with,

First Error

WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT name FROM wdir_terms WHERE term_id= made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, inherit_template, include('/themes/xxxxxx/archives/archive-6.php'), _get_category_name_by_ID

PHP Fatal error: Call to undefined function custom_permalinks_original_post_link() in /wp-content/themes/xxxxxx/archives/archive-6.php on line 253

Section of code from archive-6.php

                    <p class="quickquotetext"><strong>Quick Quotes</strong>: <a href="#" class="quoteform">Click here</a> to email the "<? echo single_cat_title(); ?>" service providers in <?php echo _get_category_name_by_ID($_GET['cat']); ?></p>

                <?php } else { // this is the normal post loop?>

                    <? global $wp_query; global $post; query_posts(array_merge(array('posts_per_page' => '-1', 'orderby' => 'title', 'order' => 'ASC'),$wp_query->query)); if (have_posts()) : while (have_posts()) : the_post(); 

                        $provider_logo = ob_get_clean();
                        if( has_post_thumbnail() ) {
                            $provider_logo = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
                            $provider_logo = $provider_logo[0];


Second Error

Stack trace:

#0 /home/xxx/wp-content/plugins/category-icons/category_icons.php(1048): wpdb->prepare('CREATE TABLE IF...')
#1 /home/xxx/wp-includes/class-wp-hook.php(286): ig_caticons_install('')
#2 /home/xxx/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#3 /home/xxx/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#4 /home/xxx/wp-settings.php(450): do_action('init')
#5 /home/xxx/wp-config.php(87): require_once('/home/ in /home/xxx/wp-includes/wp-db.php on line 1222
PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /home/xxx/wp-content/plugins/category-icons/category_icons.php on line 1048 and defined in /home/xxx/wp-includes/wp-db.php on line 1222

closed as off-topic by Mark Kaplun, Mayeenul Islam, Jacob Peattie, Nathan Johnson, Fayaz Apr 4 '18 at 15:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?" – Mark Kaplun, Mayeenul Islam, Jacob Peattie, Nathan Johnson, Fayaz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • hmm the errors are explicit enough, just need to fix them. Redoing some of the code is probably in order for example you should never use query_posts – Mark Kaplun Apr 4 '18 at 7:04
  • Thanks Mark, Im more of a IT guy vs Dev. I have fixed most already, bar these. – user7036837 Apr 4 '18 at 7:26

The error messages are pretty straightforward.

First error:

custom_permalinks_original_post_link() is not defined. It might be one defined by a plugin called "Custom Permalinks". See https://github.com/GSA/custom-permalinks/blob/master/custom-permalinks.php.

If you need that functionality, install/activate the plugin or refactor your code.

Second error:

It's clear that the category-icons plugin is doing something wrong and not calling wpdb::prepare() properly. You should ask the developer to update their plugin or find an alternative. Perhaps WP Term Icons is such an alternative.

Not the answer you're looking for? Browse other questions tagged or ask your own question.