• The plugin: “Categorical Links Page” isn’t working on my site.

    It’s a straighforward plug-in, yet I couldn’t find it listed on the 2.1 compatibility list — either as working or not (I’m running 2.2.3).

    Perhaps I have another error on my site?? Can anyone please take a quick look and let me know any problems that might cause it to not work??

    The plugin should offer a list of all the posts on my site here: http://growandknow.com/learning/?page_id=12

    I’m sorry if this is a stupid error or something — still new, and trying to use WordPress as a CMS.

Viewing 15 replies - 1 through 15 (of 15 total)
  • There were changes to the database schema in WordPress 2.3 that are at fault here:

    http://wordpress.org/support/topic/135564

    However, a single change to Categorical Links Page’s plugin file will fix things. Just look for this line in the plugin:

    $linkcats = $wpdb->get_results("SELECT DISTINCT cat_id, cat_name FROM {$wpdb->categories}");

    and change it to this (overly long bit):

    $linkcats = $wpdb->get_results("SELECT DISTINCT $wpdb->terms.term_id AS cat_id, name AS cat_name FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.taxonomy = 'link_category'");
    Thread Starter websta

    (@websta)

    Thanks for your response, but I get an error. I deactivated the plugin, changed the text and re-uploaded the file (was worried about line breaks in the plugin editor), and activated the plugin. Now I get the following error at http://growandknow.com/learning/?page_id=12:

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .te]
    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .term_id AND .taxonomy = ‘link_category’

    Make sure you get the whole line of code Kaf put there.

    Pasted Kaf’s fix here:
    http://wordpress.pastebin.ca/781898

    Thread Starter websta

    (@websta)

    I re-pasted it in, but still just an error. Here is the error:

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .te]
    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .term_id AND .taxonomy = ‘link_category’

    Here is what the plugin has now:

    <?php
    /*
    Plugin Name: Categorical Links Page
    Plugin URI: http://www.alucinari.net/wordpress
    Description:  Output links seperated by categories onto a static page (Based on Links Page (http://www.asymptomatic.net/wp-hacks) by Owen Winkler.)
    Version: 1.1
    Author: Jeremy Albrecht
    Author URI: http://www.alucinari.net/
    */
    ?>
    <?php
    /*
    
    INSTRUCTIONS
    ------------
    1. Upload this file into your wp-content/plugins directory.
    2. Activate the Links Page with Categories plugin in your WordPress admin panel.
    3. Create a new static page.
    4. Add <!--catlinkspage--> to the static page content where you want the links
    to appear.
    
    Enjoy!
    
    */
    ?>
    <?php
    
    define('LINK_USE_UL', false);
    
    function catlinks_page_callback()
    {
    	global $wpdb;
    	$output = '';
    	$linkcats = $wpdb->get_results("SELECT DISTINCT $wpdb->terms.term_id AS cat_id, name AS cat_name FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.taxonomy = 'link_category'");
    	$output .= '<div class="catlinkspage">';
    	foreach($linkcats as $cat)
    	{
        $links = get_links($cat->cat_id, '<li class="clplink">', '</li>', '<br /> >> ', true, 'name', true, false, -1, true, false);
        if($links)
        {
          $output .= '<h2 class="clplinkcategory">' . $cat->cat_name . '</h2> ';
          $output .= '<ul class="clplinklist"> ';
          $output .= $links;
          $output .= '</ul> ';
        }
        else
        {
          $output .= '';
        }
    	}
      $output .= '</div>';
    	return $output;
    }
    
    function catlinks_page($content)
    {
      if ( strpos($content, '<!--catlinkspage-->') !== false ) $content = catlinks_page_callback();
      return $content;
    }
    
    add_filter('the_content', 'catlinks_page');
    
    ?>

    Plugin as you pasted it here works fine for me.

    For some reason the tables are disappearing in your query. Note for example:

    $wpdb->terms

    should output the terms table name (typically wp_terms), but the error you get shows in this portion:

    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM

    whereas what it should be is something like:

    SELECT DISTINCT wp_terms.term_id AS cat_id, name AS cat_name FROM wp_terms

    Normally this may happen because $wpdb (WP’s database object class) is not properly scoped. That’s not the case here as the line global $wpdb; takes care of it. We didn’t change anything in the behavior of the plugin by just modifying the query line beyond (of course) correcting the query. *And* $wpdb->get_results() seems to be functioning.

    Let’s try this — I uploaded the modded plugin file to my site. Download it and overwrite yours with my copy.

    http://guff.szub.net/download/categoricallinkspage.php

    Thread Starter websta

    (@websta)

    I appreciate your help. I downloaded your version of the file and replaced it — tried deactivating other plugins, etc. I’m sorry but I continue getting the error:

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .te]
    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .term_id AND .taxonomy = ‘link_category’

    Any ideas on what can be done?

    Weird. One more thing to try…

    You could call the tables physically in the query, such as wp_terms instead of $wpdb->terms, etc. But looking back at the original query code, I think we should return to the curly braces ({}) to force WordPress to evaluate the object variables. So, the line once again:

    $linkcats = $wpdb->get_results("SELECT DISTINCT {$wpdb->terms}.term_id AS cat_id, name AS cat_name FROM {$wpdb->terms} INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND {$wpdb->term_taxonomy}.taxonomy = 'link_category'");

    Thread Starter websta

    (@websta)

    Thank you for your response Kafkaesqui. I still get the error at http://growandknow.com/learning/?page_id=12:

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .te]
    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .term_id AND .taxonomy = 'link_category'

    Is it possible there is something wrong with my databases or install? The site seems to work well otherwise.

    <?php
    /*
    Plugin Name: Categorical Links Page
    Plugin URI: http://www.alucinari.net/wordpress
    Description:  Output links seperated by categories onto a static page (Based on Links Page (http://www.asymptomatic.net/wp-hacks) by Owen Winkler.)
    Version: 1.1
    Author: Jeremy Albrecht
    Author URI: http://www.alucinari.net/
    */
    ?>
    <?php
    /*
    
    INSTRUCTIONS
    ------------
    1. Upload this file into your wp-content/plugins directory.
    2. Activate the Links Page with Categories plugin in your WordPress admin panel.
    3. Create a new static page.
    4. Add <!--catlinkspage--> to the static page content where you want the links
    to appear.
    
    Enjoy!
    
    */
    ?>
    <?php
    
    define('LINK_USE_UL', false);
    
    function catlinks_page_callback()
    {
    	global $wpdb;
    	$output = '';
    	$linkcats = $wpdb->get_results("SELECT DISTINCT $wpdb->terms.term_id AS cat_id, name AS cat_name FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.taxonomy = 'link_category'");
    	$output .= '<div class="catlinkspage">';
    	foreach($linkcats as $cat)
    	{
        $links = get_links($cat->cat_id, '<li class="clplink">', '</li>', '<br /> >> ', true, 'name', true, false, -1, true, false);
        if($links)
        {
          $output .= '<h2 class="clplinkcategory">' . $cat->cat_name . '</h2> ';
          $output .= '<ul class="clplinklist"> ';
          $output .= $links;
          $output .= '</ul> ';
        }
        else
        {
          $output .= '';
        }
    	}
      $output .= '</div>';
    	return $output;
    }
    
    function catlinks_page($content)
    {
      if ( strpos($content, '<!--catlinkspage-->') !== false ) $content = catlinks_page_callback();
      return $content;
    }
    
    add_filter('the_content', 'catlinks_page');
    
    ?>
    Thread Starter websta

    (@websta)

    nouman6, thanks for the code(poetry). I replaced the previous file with the code above, yet still got the following (located at http://growandknow.com/learning/?page_id=12 :

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .te]
    SELECT DISTINCT .term_id AS cat_id, name AS cat_name FROM INNER JOIN ON .term_id = .term_id AND .taxonomy = 'link_category'

    update your wordpress version.

    Thread Starter websta

    (@websta)

    I upgraded to 2.3.1. With the different versions, here’s what I get at http://growandknow.com/learning/?page_id=12 :

    – With nouman6’s version, no content appears (including text).
    – With Kafkaesqui’s downloadable version, again no content appears.
    – Kaf’s fix that MichaelH posted, no content either.
    – With the original plugin, available for download from the WordPress site, I get the error:

    WordPress database error: [Table 'anyth1n6.wp_categories' doesn't exist]
    SELECT DISTINCT cat_id, cat_name FROM wp_categories

    FWIW, the “Code” view of the page’s entry actually reads:

    This: "<!--catlinkspage-->" is pasted in the Code content below.
    
    <!--catlinkspage-->
    
    <code><!--catlinkspage--></code>

    I’m sorry, I feel completely idiotic at this point. Is there another plugin that does the same/similar?

    you know this plugin is for Blogroll right? do you have any?

    Hi,

    I just found this plugin (so thankful!) and had the same error as the OP. But I implemented the change that Kafkaesqui posted and it’s now working perfectly. So, it must be an issue with your WP install.

    Here’s the page I’m working on. As of right now, I still need to style the list, but it’s working!

    Thread Starter websta

    (@websta)

    Thanks for the info everyone. It’s working fine now.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘“Categorical Links Page” plugin not working!? Not working in 2.1, or…?’ is closed to new replies.