The MU forums have moved to WordPress.org

Problems with Out There (6 posts)

  1. kahless
    Member
    Posted 17 years ago #

    Actually there are two themes that are having troubles with MU. I think both use the same code for their links in the sidebar. Here is what is being used

    <h3><?php _e('Links','bnOutThere'); ?></h3>
    <?php
    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    foreach ($link_cats as $link_cat) {
    ?>
    <h4 id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?></h4>
    <ul>
    <?php wp_get_links($link_cat->cat_id); ?>
    </ul>
    <?php } ?>

    My db doesn't have a linkcategories for any blog. Should it? In fact it seems that things changed and I didn't notice but you don't have separate categories for links anymore. Any suggestions on how to alter the above to work with the new setup?

  2. kahless
    Member
    Posted 17 years ago #

    It would seem that somehow we now need to use link2cat in conjunction with categories to accomplish what the above was doing. Am I right? This code is pulling all the categories storing them and then running through styling each category name and listing the links under that category. Here is the SQL for getting what we want

    SELECT wp_1_categories.cat_name, wp_1_link2cat.category_id
    FROM wp_1_categories, wp_1_link2cat

    How do I turn this into code for WPMU query? I think it should be something like

    SELECT $wpdb->categories.cat_name, $wpdb->link2cat.category_id
    FROM $wpdb->categories, $wpdb->link2cat

    but I can't get any combinations to work. Suggestions?

  3. kahless
    Member
    Posted 17 years ago #

    Got it to work not sure if it is the cleanest solution but it works.

    <h3><?php _e('Links','bnOutThere'); ?></h3>
    <?php
    $link_cats = $wpdb->get_results("SELECT DISTINCT cat_name, category_id FROM $wpdb->categories INNER JOIN $wpdb->link2cat ON $wpdb->categories.cat_id=$wpdb->link2cat.category_id");
    foreach ($link_cats as $link_cat) {
    ?>
    <h4 id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?></h4>
    <ul>
    <?php wp_get_links($link_cat->category_id); ?>
    </ul>
    <?php } ?>

  4. mrjcleaver
    Member
    Posted 17 years ago #

    In wp-content/themes from the themepack:

    beauty-within(tp)/archives.php: $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    beauty-within(tp)/links.php: $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    connections(tp)/links.php: $cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    connections(tp)/sidebar.php: $cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    daisy-raege-mini(tp)/sidebar.php: $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    dixie-belle(tp)/sidebar.php: $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");

    ... these are likely all wrong

  5. mrjcleaver
    Member
    Posted 17 years ago #

    So... I did (for connections reloaded anyway):

    if (substr(get_bloginfo('version'), 0, 3) < 2.1)
    {
    $cats = $wpdb->get_results("SELECT DISTINCT cat_name, category_id FROM\
    $wpdb->categories INNER JOIN $wpdb->link2cat ON $wpdb->categories.cat_id=$wpdb->link2cat.category_id");
    //get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    }
    else
    {
    $cats = get_categories("type=link&orderby=name&order=ASC&hierarchical=\
    0");
    }

    and in sidebar.php:

    // $cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    $cats = $wpdb->get_results("SELECT DISTINCT cat_name, category_id FROM $wpdb->categori\
    es INNER JOIN $wpdb->link2cat ON $wpdb->categories.cat_id=$wpdb->link2cat.category_id");

    Thanks to kahless for leaving the trail. :)

  6. eljustino
    Member
    Posted 17 years ago #

    kahless
    I know this is coming months after this thread started, but your fix worked perfectly. I can't imagine a cleaner method.

    Thanks!

    Justin

About this Topic

  • Started 17 years ago by kahless
  • Latest reply from eljustino