Support » Plugin: Business Directory Plugin » List Titles under Categories

  • Resolved fidgeter


    I’m attempting to do a main listings page with everyone in the directory sorted alphabetically under the Category.
    Similar to this page:

    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(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author businessdirectoryplugin


    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.

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Titles under Categories’ is closed to new replies.