• Resolved webforge

    (@webforge)


    In http://plugins.svn.wordpress.org/wp-business-directory-manager/trunk/posttemplate/wpbusdirman-category.php there are 2 issues regarding:

    *category filtering – clicking on a category from the business directory page does not filter properly when there are multiple categories used in the directory manager as $wpbusdirman_postcatitems is being passed as the parameter category__in in the query_posts function. This results in all posts from all categories being displayed. To correct this issue, the parameter cat needs to be set to the return value of get_query_var('cat') and passed to the query_posts function

    *page navigation – when there are more than 10 (or whatever value you have set for number of posts to display) posts in a category, paging does not work as the parameter paged is not being passed to the query_posts function. This results in the first 10 records always being displayed.

    FIX:

    At line 164 of posttemplate/wpbusdirman-category.php

    change:

    $args=array(
               'category__in'=>$wpbusdirman_postcatitems,
               'post__not_in' => $wpbusdirman_approvedfeatured,
               );

    to:

    $pagenum = get_query_var('paged');
    $paged = (!empty($pagenum) ? $pagenum : 1);
    
    $args=array(
               'cat' => get_query_var('cat'),
               'post__not_in' => $wpbusdirman_approvedfeatured,
               'paged' => $paged
               );

    There may be more elegant ways of coding the above but this code seems to work okay. 🙂

    http://wordpress.org/extend/plugins/wp-business-directory-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thanks, webforge! Stumbled on this, very helpful.

    Would you mind explaining the category filtering issue a little more? I’m still learning PHP, and could use line locations and exactly what I’m replacing with what, so I can’t wreak too much havoc.

    On another category note (if you don’t mind), I’m trying to figure out exactly how I can allow users to select more than one category for their listing. Any words of wisdom?

    Thread Starter webforge

    (@webforge)

    Hi ampKathy,

    In the above code, the $args array is set up to contain a list of parameters to pass to the query_posts function. The query_posts function can return different lists of posts depending on what parameters are passed to it i.e. query_posts($args); at line 170 of posttemplate/wpbusdirman-category.php

    In the first chunk of code above, $args passes through the category__in parameter with the value of $wpbusdirman_postcatitems. The $wpbusdirman_postcatitems is an array that contains a list of all categories used by WPBDM – see the ‘Directory Category IDs’ option: Dashboard >> WPBusDirMan >> Manage Options. Passing through $wpbusdirman_postcatitems as the category__in parameter will get the query_posts function to return all posts from all categories (i.e. all posts in the Business Directory) used by WPBDM.

    This means that when you click on a category in the Business Directory listings page that you will get back a listing of all posts from all categories rather than just posts from the category that you clicked on.

    The second chunk of code above fixes this issue by passing through the cat parameter instead (which expects a single value rather than an array) with the value set to the category id parameter from the clicked URL’s query string.

    In answer to your second question, at the moment the submit a listing form only allows for one category using the select box in the form. Multiple categories could be selected through the use of checkboxes or a select box allowing multiple selections. Perhaps for a future release???

    In the meantime, a user submitting a listing will only be able to select one category. The administrator can of course select additional categories for the listing post when approving the listing…

    @themestown – Good work so far with the plugin – I hope my contributions help with its development 🙂

    Thanks for the great explanation about the category filters, I got it now. 🙂

    I know the plugin only allows one category, just hoping someone had played around with it (trying to stay completely out of the listing process). Fingers crossed that it’s included in a future release.

    Thanks again, webforge! You rock.

    And I ditto the sentiment about WPBDM — I think it’s developing into the best WP directories out there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP BUSINESS DIRECTORY MANAGER] Category filtering and paging bug’ is closed to new replies.