Support » Plugin: Connections Business Directory » [Plugin: Connections] Listing incorrectly displayed under wrong category

  • Resolved borjawebs


    We created a listing for a business under two categories. However, when we go back to look for them in the display view labeled “Business Directory,” it is not under the categories we specified. A closer look revealed it was actually showing up in a totally separate, unrelated category.

    The display view is just a page with this in it:

    [connections order_by=’category’]

    Any ideas as to what’s going on? Here are the listing details:

    Business: Designs with Hope
    Categories set to: Advertising, Graphic Design / Advertising
    But instead shows up in: Home Health Services

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author shazahm1


    I actually do not think I can help. I’d have to have a temp access to see what you’re doing. The only thing I can say is that the shortcode [connections order_by='category'] is not valid. There is no option to sort by category.

    Will this be a feature supported soon?

    Plugin Author shazahm1


    Not likely. I would more likely add a group_by option so one can group by different objects and then order them within that grouping, but I would not expect for this feature to be implemented soon.

    You think standard MySQL queries and joins would be sufficient for just rendering a view like this, organized by categories? e.g. setting it as a page template and leave it like that?

    Alright, so seeing that this feature is not going to be available soon, allow me to contribute to this part of the Connections plugin.

    A simple WordPress Page Template that simply displays listings from the Connections plugin’s database and renders a category sorted view. This is the minimal amount of coding required to do this, allowing you flexibility to modify any way you want.

    Please share:

    Template Name: Business Directory (Connections)
    $terms = array();
    $q = mysql_query('SELECT * FROM wp_connections_terms');
    while($row = mysql_fetch_object($q)) {
       $terms[$row->term_id] = array(
          'meta' => $row,
          'listings' => array()
    $q = mysql_query('
       SELECT *
       FROM wp_connections
       INNER JOIN wp_connections_term_relationships ON wp_connections_term_relationships.entry_id =
       INNER JOIN wp_connections_term_taxonomy ON wp_connections_term_taxonomy.term_taxonomy_id = wp_connections_term_relationships.term_taxonomy_id
    while($row = mysql_fetch_object($q)) {
       $email = unserialize($row->email);
       $email = array_pop($email);
       $email = str_replace('@', ' (at) ', $email['address']);
       $row->email = $email;
       $phone = unserialize($row->phone_numbers);
       $phone  = array_pop($phone);
       $row->phone = $phone['number'];
       array_push($terms[$row->term_id]['listings'], $row);
    <?php get_header(); ?>
    <style type="text/css"> {
    	font: 12px Arial, Tahoma, sans-serif;
    } a {
    	color: #369;
    } tr th, tr td {
    	vertical-align: middle;
    	text-align: left;
    	padding: 5px;
    } tr th {
    	padding-top: 25px;
    	border-bottom: 1px solid #def;
    	color: #369;
    	font-size: 14px;
    } tr td {
    color: #555;
    } tr:hover td {
    	background: #f5f5ff;
    <div class="span-24" id="contentwrap">
        <?php get_sidebars('left'); ?>
        <div class="span-18">
            <div id="content">
             <h2>Business Directory</h2>
             <table class="directory" cellspacing="0">
                <?php foreach($terms as $t) : ?>
                <th colspan="3" style="padding-top: 0;"><?php echo $t['meta']->name; ?></th>
                   <?php foreach($t['listings'] as $l) : ?>
                   <td align="left" valign="top"><?php echo $l->organization; ?></td>
                   <td align="left" valign="top" nowrap="nowrap"><?php echo $l->phone; ?></td>
                   <td align="left" valign="top"><?php echo $l->email; ?></td>
                   <?php endforeach; ?>
                   <tr><td colspan="3" style="padding: 10px 0;"></td></tr>
                <?php endforeach; ?>
    <?php get_footer(); ?>

    Here’s a little value add. Helps to unify the phone number format where various formats may be used:

    $default_area_code = '555';
       $phone = unserialize($row->phone_numbers);
       $phone  = array_pop($phone);
       $phone = $phone['number'];
       // Filters
       $length = strlen(preg_replace('/[^\d]/', '', $phone));
       // No area code
       if($length == 7)
       $phone = $default_area_code . '-' . $phone;
       $filtered = preg_replace('/^\(?(\d+)\)?\s*\-*(\d+)\-?(\d+)(\w*)(\d*)/', '(\1) \2-\3 \4\5', $phone);
       // $phone .= '<!-- Filtered as '.$filtered.'-->';
       $phone = $filtered;
       $row->phone = $phone;
    Plugin Author shazahm1



    Yes, joins are exactly how this would be accomplished as you demonstrated. However, the above code was not incorporated within the proper retrieve method and as such bypasses all the features built-in to that code which builds the queries for Connections. Probably most importantly, it completely bypasses the public/private/unlisted visibility and approved/pending status of entries and their associated data. Adding this to the proper retrieve method is not so simple because of the many other variables that have to be taken into consideration which requires a lot of testing. Breaking that method would be unacceptable as it would break 10’s of thousands of directories.

    I am glad you found a solution that worked for you, but unless others know precisely what they are doing, I can not recommend using the above code. I’m sure you can appreciate that.

    What exactly does the “proper retrieve method” entail?

    Plugin Author shazahm1



    Look in the class.retrieve.php under the retrieve method.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Connections] Listing incorrectly displayed under wrong category’ is closed to new replies.