Business Directory Plugin
[resolved] List Titles under Categories (3 posts)

  1. fidgeter
    Posted 2 years ago #

    I'm attempting to do a main listings page with everyone in the directory sorted alphabetically under the Category.
    Similar to this page: http://www.health-first.org/physician/hfmg_list.cfm

    Now what I've done is run a query for posts within the WPBDP_POST_TYPE. The Categories for BDP is different than the stock wordpress Categories so I can't use $args to establish categories, correct? What I've done is below but I'm afraid if I have to run Queries for each category it'll slow the page down. Is there a better way to do this or a command within BDP I've missed?

    An example of what I've done to pull the ones that are in "category 5".

    $args = array( 'post_type' => WPBDP_POST_TYPE, 'orderby' => 'title', 'order' => 'ASC' );
    	<?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
    	<?php $value = wp_get_object_terms( $id, WPBDP_CATEGORY_TAX, array( 'fields' => 'ids' ) ); ?>
        <?php if(in_array("5", $value)): ?>
    	<p><a href="<?php the_permalink(); ?>">
        <?php the_title(); ?>
    	<?php endif; ?>
    	<?php endwhile; ?>
        <?php endif; ?>
    <?php wp_reset_query(); ?>


  2. businessdirectoryplugin
    Plugin Author

    Posted 2 years ago #

    I don't know if there's a better way to do it than what you have above. But your concern is valid, you could have performance problems with excessive category subqueries.

  3. fidgeter
    Posted 2 years ago #

    Thank you for your response. My optimal solution may be to just not have it query at all and manually create the page with the list and link them to the relevant Business Directory pages. It's a little more work on my part but would mean a lot less overhead for the server.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Business Directory Plugin
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.